#102194Paginator for QueryBuilder
Description
Currently there’s two Paginators in the core:
- \TYPO3\CMS\Core\Pagination\ArrayPaginator
- \TYPO3\CMS\Extbase\Pagination\QueryResultPaginator
Neither of them is ideal for QueryBuilder results, right?
Sure we could use ArrayPaginator like this:
$query = $queryBuilder->select('*')->from('tt_content');
new ArrayPaginator($query->executeQuery()->fetchAll(), $currentPage, $itemsPerPage);
But this will always fire the whole SELECT statement without any LIMIT to the database.
I suggest to add a 3rd paginator to the core: QueryResultPaginator
Reviews 4
Related issues 1
History 611
-
Gerrit Code Review pushed patch set 1 for main to change 81447 status
NewUnder Review <span data-processor="relativetime" data-value="2023-10-18T11:37:47+00:00" > 10/18/23, 11:37 </span> -
Gerrit Code Review pushed patch set 2 for main to change 81447 <span data-processor="relativetime" data-value="2023-10-18T12:16:28+00:00" > 10/18/23, 12:16 </span>
-
Bastian Stargazer commented <span data-processor="relativetime" data-value="2023-12-28T13:43:38+00:00" > 12/28/23, 13:43 </span>
-
Stefan Bürk commented and changed status
Under ReviewRejected <span data-processor="relativetime" data-value="2025-01-09T08:56:10+00:00" > 01/09/25, 08:56 </span>Rejectiong this request as “Won’t do” as this is currently not doable in a working way,
at least as a generic overall solution which TYPO3 should strive for.See comments in the provided change, but the current solution
lacks support for two major things:- Full record language overlay handling
- Full workspace support (moved,deleted,added in workspace, resorted, …)
That means the plain QueryBuilder paginator could only be used in single language (default)
instance without workspaces and is not reliable in instances using one or both and leading
to a fallout of upcoming multipe issues targeting the missing support and asking why it
does not automatically resolve these things.I don’t see any easy way to implement this in a satisfing way even with a lot of time investment
plus the time required to deal with the following issue reports.I’d suggest to provide this paginator implementation as a dedicated extension mentioning the restriction.
-
Christian Weiske commented <span data-processor="relativetime" data-value="2026-01-19T07:28:16+00:00" > 01/19/26, 07:28 </span>
I’m using the following code since some time.
And yes, it doesn’t support language overlays or workspaces.<?php declare(strict_types=1); namespace Vendor\Example\Helper; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Pagination\AbstractPaginator; /** * Copy of TYPO3\CMS\Extbase\Pagination\QueryResultPaginator * that supports a QueryBuilder as source */ class QueryBuilderPaginator extends AbstractPaginator { private QueryBuilder $queryBuilder; private array $paginatedQueryResult; public function __construct( QueryBuilder $queryBuilder, int $currentPageNumber = 1, int $itemsPerPage = 10 ) { $this->queryBuilder = $queryBuilder; $this->setCurrentPageNumber($currentPageNumber); $this->setItemsPerPage($itemsPerPage); $this->updateInternalState(); } public function getPaginatedItems(): iterable { return $this->paginatedQueryResult; } protected function updatePaginatedItems(int $limit, int $offset): void { $this->paginatedQueryResult = $this->queryBuilder ->setMaxResults($limit) ->setFirstResult($offset) ->execute() ->fetchAllAssociative(); } protected function getTotalAmountOfItems(): int { return (clone $this->queryBuilder)->count('uid')->executeQuery()->fetchOne(); } protected function getAmountOfItemsOnCurrentPage(): int { return count($this->paginatedQueryResult); } } -
Gerrit Code Review pushed patch set 7 for main to change 91373 status
RejectedUnder Review <span data-processor="relativetime" data-value="2026-03-06T06:46:10+00:00" > 03/06/26, 06:46 </span> -
Gerrit Code Review pushed patch set 8 for main to change 91373 <span data-processor="relativetime" data-value="2026-03-06T09:31:31+00:00" > 03/06/26, 09:31 </span>
-
Gerrit Code Review pushed patch set 9 for main to change 91373 <span data-processor="relativetime" data-value="2026-03-06T09:57:16+00:00" > 03/06/26, 09:57 </span>
-
Georg Ringer commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-03-06T12:40:08+00:00" > 03/06/26, 12:40 </span>Applied in changeset commit:dd36bc807a01d706f8780b8a502234d16919542f.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2026-03-31T09:00:37+00:00" > 03/31/26, 09:00 </span> -
Chris Müller changed Related to #109821 <span data-processor="relativetime" data-value="2026-05-12T08:38:54+00:00" > 05/12/26, 08:38 </span>
Will this feature patch also be available in v11? That would be awesome!