diff --git a/classes/format.class.php b/classes/format.class.php index b726728b9..32394c74c 100644 --- a/classes/format.class.php +++ b/classes/format.class.php @@ -159,19 +159,6 @@ public static function page_limit($PerPage, $DefaultResult = 1) { return [$Page, $Limit]; } - // A9 magic. Some other poor soul can write the phpdoc. - // For data stored in memcached catalogues (giant arrays), e.g. forum threads - public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500) { - $CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize); - $CatalogueLimit = ($CatalogueID * $CatalogueSize).", $CatalogueSize"; - return [$CatalogueID, $CatalogueLimit]; - } - - public static function catalogue_select($Catalogue, $Page, $PerPage, $CatalogueSize = 500) { - return array_slice($Catalogue, (($PerPage * $Page - $PerPage) % $CatalogueSize), $PerPage, true); - } - - /* Get pages * Returns a page list, given certain information about the pages. * diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 081fe2dbf..a666443f4 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -71,9 +71,9 @@ if (($Page - 1) * $PerPage > $threadInfo['Posts']) { $Page = ceil($threadInfo['Posts'] / $PerPage); } -[$CatalogueID, $CatalogueLimit] = Format::catalogue_limit($Page, $PerPage, THREAD_CATALOGUE); // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page +$CatalogueID = floor(($PerPage * ($Page - 1)) / THREAD_CATALOGUE); if (!$Catalogue = $Cache->get_value("thread_$threadId"."_catalogue_$CatalogueID")) { $DB->prepared_query(" SELECT @@ -86,15 +86,15 @@ FROM forums_posts AS p WHERE p.TopicID = ? AND p.ID != ? - LIMIT ? - ", $threadId, $threadInfo['StickyPostID'], $CatalogueLimit + LIMIT ? OFFSET ? + ", $threadId, $threadInfo['StickyPostID'], THREAD_CATALOGUE, $CatalogueID * $CatalogueSize ); $Catalogue = $DB->to_array(false, MYSQLI_ASSOC); if (!$threadInfo['isLocked'] || $threadInfo['isSticky']) { $Cache->cache_value("thread_$threadId"."_catalogue_$CatalogueID", $Catalogue, 0); } } -$Thread = Format::catalogue_select($Catalogue, $Page, $PerPage, THREAD_CATALOGUE); +$Thread = array_slice($Catalogue, ($PerPage * ($Page - 1)) % THREAD_CATALOGUE, $PerPage, true); if ($_GET['updatelastread'] !== '0') { $LastPost = end($Thread);