[BUGFIX] Break out of foreach if there're no rows in table 54/27554/8
authorStefan Froemken <froemken@gmail.com>
Tue, 11 Feb 2014 18:10:11 +0000 (19:10 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 4 Mar 2014 16:13:06 +0000 (17:13 +0100)
Instead of using a slow COUNT on huge tables, we add an
additional query here, which tries to get the first
found record in oder to test if records exists
or not. This new query is extremely fast, because it
uses indexes. It only needs one huge table
like sys_log in your database to see a performance
boost in BE list module.

Resolves: #55891
Releases: 6.2
Change-Id: I920729421bcece8af3b7cdd5f53446e5a1be5300
Reviewed-on: https://review.typo3.org/27554
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Oliver Klee
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php

index 9ed6f13..63ba0eb 100644 (file)
@@ -405,10 +405,19 @@ class AbstractDatabaseRecordList extends \TYPO3\CMS\Backend\RecordList\AbstractR
                                if ($hideTable) {
                                        continue;
                                }
-                               // iLimit is set depending on whether we're in single- or multi-table mode
+                               // check if we are in single- or multi-table mode
                                if ($this->table) {
                                        $this->iLimit = isset($GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems']) ? (int)$GLOBALS['TCA'][$tableName]['interface']['maxSingleDBListItems'] : $this->itemsLimitSingleTable;
                                } else {
+                                       // if there are no records in table continue current foreach
+                                       $firstRow = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                                               'uid',
+                                               $tableName,
+                                               $this->pidSelect . BackendUtility::deleteClause($tableName) . BackendUtility::versioningPlaceholderClause($tableName)
+                                       );
+                                       if ($firstRow === FALSE) {
+                                               continue;
+                                       }
                                        $this->iLimit = isset($GLOBALS['TCA'][$tableName]['interface']['maxDBListItems']) ? (int)$GLOBALS['TCA'][$tableName]['interface']['maxDBListItems'] : $this->itemsLimitPerTable;
                                }
                                if ($this->showLimit) {