diff options
| author | 2024-04-08 14:48:30 +0200 | |
|---|---|---|
| committer | 2024-04-08 14:48:30 +0200 | |
| commit | 72933b301edf0379778e8c5f8ffee5ac06bb076b (patch) | |
| tree | 55dc6da5679d24629e9995bb46d98901ac01dcba /app/Controllers/indexController.php | |
| parent | 6e1278182155c6b1e8cef274368bd35510a2a14e (diff) | |
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
Diffstat (limited to 'app/Controllers/indexController.php')
| -rw-r--r-- | app/Controllers/indexController.php | 10 |
1 files changed, 5 insertions, 5 deletions
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<FreshRSS_Entry> * @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; |
