[BUGFIX] Prevent building empty IN () query by throwing exception
authorBenjamin Bretz <pleaserebootuniverse@googlemail.com>
Fri, 12 Apr 2013 19:55:19 +0000 (21:55 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 12 Apr 2013 19:57:37 +0000 (21:57 +0200)
If $storagePageIds is empty Typo3DbBackend::addPageIdStatement()
InconsistentQuerySettingsException is thrown instead of creating
an invalid query

Fixes: #47167
Releases: 6.1, 6.0, 1.3
Change-Id: Ib52884573c9a09b791c0b090daaffc9b7d15b6a1
Reviewed-on: https://review.typo3.org/19861
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-on: https://review.typo3.org/19866

typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php

index c4c252c..7a22eb5 100644 (file)
@@ -850,6 +850,9 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                        $this->tableInformationCache[$tableName]['columnNames'] = $this->databaseHandle->admin_get_fields($tableName);
                }
                if (is_array($GLOBALS['TCA'][$tableName]['ctrl']) && array_key_exists('pid', $this->tableInformationCache[$tableName]['columnNames'])) {
+                       if (empty($storagePageIds)) {
+                               throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\InconsistentQuerySettingsException('Missing storage page ids.', 1365779762);
+                       }
                        $sql['additionalWhereClause'][] = $tableName . '.pid IN (' . implode(', ', $storagePageIds) . ')';
                }
        }