[TASK] Avoid processing empty entity ids in DataMapProcessor 43/62343/3
authorOliver Hader <oliver@typo3.org>
Tue, 19 Nov 2019 10:41:09 +0000 (11:41 +0100)
committerBenni Mack <benni@typo3.org>
Tue, 19 Nov 2019 13:31:18 +0000 (14:31 +0100)
Avoid executing (more expensive) queries in DataMapProcessor in case
there are actually no entity ids to be retrieved from database.

Resolves: #89710
Releases: master
Change-Id: Id03d6c17d13e5969b707ad4e6c9b61f3fd9b4a07
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62343
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Gorges <daniel.gorges@b13.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Daniel Gorges <daniel.gorges@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/DataHandling/Localization/DataMapProcessor.php

index 26bebe1..d737776 100644 (file)
@@ -849,6 +849,10 @@ class DataMapProcessor
      */
     protected function fetchTranslationValues(string $tableName, array $fieldNames, array $ids)
     {
+        if (empty($ids)) {
+            return [];
+        }
+
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getQueryBuilderForTable($tableName);
         $queryBuilder->getRestrictions()
@@ -892,7 +896,7 @@ class DataMapProcessor
      */
     protected function fetchDependencies(string $tableName, array $ids)
     {
-        if (!BackendUtility::isTableLocalizable($tableName)) {
+        if (empty($ids) || !BackendUtility::isTableLocalizable($tableName)) {
             return [];
         }
 
@@ -969,6 +973,10 @@ class DataMapProcessor
      */
     protected function fetchDependentIdMap(string $tableName, array $ids, int $desiredLanguage)
     {
+        if (empty($ids)) {
+            return [];
+        }
+
         $ids = $this->filterNumericIds($ids);
         $isTranslatable = BackendUtility::isTableLocalizable($tableName);
         $originFieldName = ($GLOBALS['TCA'][$tableName]['ctrl']['origUid'] ?? null);
@@ -1049,6 +1057,10 @@ class DataMapProcessor
      */
     protected function fetchDependentElements(string $tableName, array $ids, array $fieldNames)
     {
+        if (empty($ids)) {
+            return [];
+        }
+
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getQueryBuilderForTable($tableName);
         $queryBuilder->getRestrictions()