[serendipity-cvs] [s9y/Serendipity] 93e475: Fix error when showing all comments with PHP 8.3 (...

Jens Kubieziel via php-blog-cvs <[email protected]> Mon, 04 May 2026 15:39:36 -0700
Newsgroups gmane.comp.serendipity.cvs
Message-ID <s9y/Serendipity/push/refs/heads/master/[email protected]>
  Branch: refs/heads/master
  Home:   https://github.com/s9y/Serendipity
  Commit: 93e475cb240819cb04b4b921e7a79501fb440fb3
      https://github.com/s9y/Serendipity/commit/93e475cb240819cb04b4b921e7a79501fb440fb3
  Author: Jens Kubieziel <[email protected]>
  Date:   2026-05-05 (Tue, 05 May 2026)

  Changed paths:
    M docs/NEWS
    M include/admin/comments.inc.php

  Log Message:
  -----------
  Fix error when showing all comments with PHP 8.3 (#968)

* Update comments.inc.php for compatibility with PHP 8.3

When you want to access all comments, S9Y runs into an HTTP 500:
`PHP Fatal error:  Uncaught DivisionByZeroError: Division by zero` in line 260.

The comparison of strings and integers has changed in PHP 8. See https://www.php.net/manual/en/migration80.incompatible.php

Previously the comparison in line 260 was `0 == 'all'` -> true.
Whith the changes the comparison now is `0 == 'all'` -> false. Which leads to the above mentioned error message.

I changed the code in a way that `$commentsPerPage` has either an interger or`COMMENTS_FILTER_ALL` as value and the comparison now checks type and value. So in the case of all comments the comparison is `'all' === 'all` -> true.

This should fix the code.

* document changes

---------

Co-authored-by: onli <[email protected]>



To unsubscribe from these emails, change your notification settings at https://github.com/s9y/Serendipity/settings/notifications