From 72933b301edf0379778e8c5f8ffee5ac06bb076b Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 8 Apr 2024 14:48:30 +0200 Subject: Fix paging posts per page (#6268) * Fix paging posts per page fix https://github.com/FreshRSS/FreshRSS/issues/6062 Due to strange scoping of anonymous function trying to update a static property * Better type syntax --- app/Controllers/indexController.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/Controllers/indexController.php') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 79e1a6210..17439fe27 100644 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -73,9 +73,8 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { $this->view->callbackBeforeEntries = static function (FreshRSS_View $view) { try { - FreshRSS_Context::$number++; //+1 for articles' page - $view->entries = FreshRSS_index_Controller::listEntriesByContext(); - FreshRSS_Context::$number--; + // +1 to account for paging logic + $view->entries = FreshRSS_index_Controller::listEntriesByContext(FreshRSS_Context::$number + 1); ob_start(); //Buffer "one entry at a time" } catch (FreshRSS_EntriesGetter_Exception $e) { Minz_Log::notice($e->getMessage()); @@ -244,10 +243,11 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { /** * This method returns a list of entries based on the Context object. + * @param int $postsPerPage override `FreshRSS_Context::$number` * @return Traversable * @throws FreshRSS_EntriesGetter_Exception */ - public static function listEntriesByContext(): Traversable { + public static function listEntriesByContext(?int $postsPerPage = null): Traversable { $entryDAO = FreshRSS_Factory::createEntryDao(); $get = FreshRSS_Context::currentGet(true); @@ -266,7 +266,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { foreach ($entryDAO->listWhere( $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, - FreshRSS_Context::$number, FreshRSS_Context::$offset, FreshRSS_Context::$first_id, + $postsPerPage ?? FreshRSS_Context::$number, FreshRSS_Context::$offset, FreshRSS_Context::$first_id, FreshRSS_Context::$search, $date_min) as $entry) { yield $entry; -- cgit v1.2.3