TYPO3 v12 QueryResultPaginator does not rebind limit/offset after QueryResult materialization
0 reputation · 10 Jul 2025, 00:49 UTC
When using TYPO3 v12's TYPO3\CMS\Core\Pagination\QueryResultPaginator with an Extbase repository query, the goal is to paginate a large dataset efficiently by applying setLimit() and setOffset() to the underlying query before it is executed.
However, if the Extbase QueryResult has already been materialized—by iteration, toArray(), or a count() call—before the paginator sets the limit/offset, the SQL is not rebound and the paginator may return the wrong slice or the entire result set, making the pagination unreliable.
What is the correct order to instantiate the paginator relative to query execution? How can a repository guarantee that limit/offset are applied before any materialization of the QueryResult? Should a dedicated count query always be used for large tables, and if so, how should it be combined with QueryResultPaginator?