[BUGFIX] Do not use LIMIT/OFFSET on total count query 40/53940/2
authorSusanne Moog <susanne.moog@typo3.com>
Thu, 7 Sep 2017 08:27:30 +0000 (10:27 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 7 Sep 2017 11:03:26 +0000 (13:03 +0200)
Usage of limit > 0 or offset in a count query do not
make sense and result in broken pagination in the list
module as the returned total count of items is always 0.

Reset given offsets/limit for that exact query.

Change-Id: I18b1964b860e51256a6d0a5f39fd4c40544bac85
Resolves: #82325
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/53940
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php

index c5a74c1..53c2971 100644 (file)
@@ -840,6 +840,9 @@ class AbstractDatabaseRecordList extends AbstractRecordList
         }
 
         $queryBuilder = $this->prepareQueryBuilder($table, $pageId, ['*'], $constraints, $queryBuilder, false);
+        // Reset limit and offset for full count query
+        $queryBuilder->setFirstResult(0);
+        $queryBuilder->setMaxResults(1);
 
         $this->totalItems = (int)$queryBuilder->count('*')
             ->execute()