[BUGFIX] Respect offset of original query in PaginateController 87/60487/4
authorChris Müller <typo3@krue.ml>
Tue, 16 Apr 2019 13:35:18 +0000 (15:35 +0200)
committerDaniel Goerz <daniel.goerz@posteo.de>
Mon, 2 Sep 2019 07:12:34 +0000 (09:12 +0200)
When you have set an offset on a query, the PaginateController will
now take this offset into account when browsing to a next page.

Resolves: #88159
Releases: master, 9.5
Change-Id: I0791f8550ccfff4eefab297d7000e08e6e01b93e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60487
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php

index 6412296..5a88ddb 100644 (file)
@@ -94,8 +94,11 @@ class PaginateController extends AbstractWidgetController
             // modify query
             $itemsPerPage = (int)$this->configuration['itemsPerPage'];
             $offset = 0;
+            if ($this->objects instanceof QueryResultInterface) {
+                $offset = (int)$this->objects->getQuery()->getOffset();
+            }
             if ($this->currentPage > 1) {
-                $offset = ((int)($itemsPerPage * ($this->currentPage - 1)));
+                $offset = $offset + ((int)($itemsPerPage * ($this->currentPage - 1)));
             }
             $modifiedObjects = $this->prepareObjectsSlice($itemsPerPage, $offset);
         }