diff options
Diffstat (limited to 'app/Controllers')
| -rw-r--r-- | app/Controllers/entryController.php | 2 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 2 | ||||
| -rw-r--r-- | app/Controllers/indexController.php | 34 |
3 files changed, 27 insertions, 11 deletions
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index 8e5dbaa80..be553267b 100644 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -46,7 +46,7 @@ class FreshRSS_entry_Controller extends FreshRSS_ActionController { public function readAction(): void { $get = Minz_Request::paramString('get'); $next_get = Minz_Request::paramString('nextGet') ?: $get; - $id_max = Minz_Request::paramString('idMax') ?: '0'; + $id_max = Minz_Request::paramString('idMax'); if (!ctype_digit($id_max)) { $id_max = '0'; } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index bf20f0747..cc321aa49 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -1104,7 +1104,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController { //Extract all feed entries from database, load complete content and store them back in database. $entryDAO = FreshRSS_Factory::createEntryDao(); - $entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, 'DESC', $limit); + $entries = $entryDAO->listWhere('f', $feed_id, FreshRSS_Entry::STATE_ALL, order: 'DESC', limit: $limit); //We need another DB connection in parallel for unbuffered streaming Minz_ModelPdo::$usesSharedPdo = false; diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 3737f2dfd..e2d48560e 100644 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -62,7 +62,9 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { } FreshRSS_View::prependTitle($title . ' ยท '); - FreshRSS_Context::$id_max = time() . '000000'; + if (FreshRSS_Context::$id_max === '0') { + FreshRSS_Context::$id_max = time() . '000000'; + } $this->view->callbackBeforeFeeds = static function (FreshRSS_View $view) { $view->tags = FreshRSS_Context::labels(true); @@ -84,10 +86,10 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { }; $this->view->callbackBeforePagination = static function (?FreshRSS_View $view, int $nbEntries, FreshRSS_Entry $lastEntry) { - if ($nbEntries >= FreshRSS_Context::$number) { + if ($nbEntries > FreshRSS_Context::$number) { //We have enough entries: we discard the last one to use it for the next articles' page ob_clean(); - FreshRSS_Context::$next_id = $lastEntry->id(); + FreshRSS_Context::$continuation_id = $lastEntry->id(); } ob_end_flush(); }; @@ -264,16 +266,30 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController { $id = 0; } - $date_min = 0; + $id_min = '0'; if (FreshRSS_Context::$sinceHours > 0) { - $date_min = time() - (FreshRSS_Context::$sinceHours * 3600); + $id_min = (time() - (FreshRSS_Context::$sinceHours * 3600)) . '000000'; + } + + $continuation_value = 0; + if (FreshRSS_Context::$continuation_id !== '0') { + if (in_array(FreshRSS_Context::$sort, ['date', 'link', 'title'], true)) { + $pagingEntry = $entryDAO->searchById(FreshRSS_Context::$continuation_id); + $continuation_value = $pagingEntry === null ? 0 : match (FreshRSS_Context::$sort) { + 'date' => $pagingEntry->date(true), + 'link' => $pagingEntry->link(true), + 'title' => $pagingEntry->title(), + }; + } elseif (FreshRSS_Context::$sort === 'rand') { + FreshRSS_Context::$continuation_id = '0'; + } } foreach ($entryDAO->listWhere( - $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, - $postsPerPage ?? FreshRSS_Context::$number, FreshRSS_Context::$offset, FreshRSS_Context::$first_id, - FreshRSS_Context::$search, $date_min - ) as $entry) { + $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$search, + id_min: $id_min, id_max: FreshRSS_Context::$id_max, sort: FreshRSS_Context::$sort, order: FreshRSS_Context::$order, + continuation_id: FreshRSS_Context::$continuation_id, continuation_value: $continuation_value, + limit: $postsPerPage ?? FreshRSS_Context::$number, offset: FreshRSS_Context::$offset) as $entry) { yield $entry; } } |
