diff --git a/docs/NEWS b/docs/NEWS index 26ec65265..d4fd2734b 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -1,6 +1,9 @@ Version 2.7-alpha1 () ------------------------------------------------------------------------ + * Fix division by zero error when accessing all PHP comments on PHP 8 + (thanks to @qbi) + * Fix error message and 404 status code on plugin pages when cache was active (thanks to @fasterit/DLange) diff --git a/include/admin/comments.inc.php b/include/admin/comments.inc.php index 7e4fd5198..d9716d585 100644 --- a/include/admin/comments.inc.php +++ b/include/admin/comments.inc.php @@ -6,7 +6,11 @@ $data = array(); -$commentsPerPage = (int)(!empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10); +$commentsPerPage = !empty($serendipity['GET']['filter']['perpage']) ? $serendipity['GET']['filter']['perpage'] : 10; +if ($commentsPerPage != COMMENTS_FILTER_ALL) { + $commentsPerPage = (int)($commentsPerPage); +} + $summaryLength = 200; $errormsg = array(); @@ -257,7 +261,7 @@ $sql = serendipity_db_query("SELECT COUNT(*) AS total FROM {$serendipity['dbPrefix']}comments c WHERE 1 = 1 " . ($c_type !== null ? " AND c.type = '$c_type' " : '') . $and, true); $totalComments = $sql['total']; -$pages = ($commentsPerPage == COMMENTS_FILTER_ALL ? 1 : ceil($totalComments/(int)$commentsPerPage)); +$pages = ($commentsPerPage === COMMENTS_FILTER_ALL ? 1 : ceil($totalComments/(int)$commentsPerPage)); if (isset($serendipity['GET']['page'])) { $page = (int)$serendipity['GET']['page']; } else { @@ -271,7 +275,7 @@ $linkNext = 'serendipity_admin.php?serendipity[adminModule]=comments&serendipity[page]='. ($page+1) . $searchString; $filter_vals = array(10, 20, 50, COMMENTS_FILTER_ALL); -if ($commentsPerPage == COMMENTS_FILTER_ALL) { +if ($commentsPerPage === COMMENTS_FILTER_ALL) { $limit = ''; } else { $limit = serendipity_db_limit_sql(serendipity_db_limit(($page-1)*(int)$commentsPerPage, (int)$commentsPerPage));