[BUGFIX] Use correct database connection for table in ReferenceIndex 44/53144/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Tue, 6 Jun 2017 03:55:38 +0000 (20:55 -0700)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 6 Jun 2017 18:46:55 +0000 (20:46 +0200)
Reusing the connection object for the sys_refindex table can fail
if the table that is being indexed is actually on another connection.
Select the proper connection before attempting to execute the query.

Change-Id: I4c031428f7405031aea6ef652c8b6f488f921228
Resolves: #81049
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/53144
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Database/ReferenceIndex.php

index 4598632..ea1fba7 100644 (file)
@@ -207,7 +207,8 @@ class ReferenceIndex
             $tableRelationFields = $this->runtimeCache->get($cacheId);
         }
 
-        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_refindex');
+        $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
+        $connection = $connectionPool->getConnectionForTable('sys_refindex');
 
         // Get current index from Database with hash as index using $uidIndexField
         // no restrictions are needed, since sys_refindex is not a TCA table
@@ -227,7 +228,7 @@ class ReferenceIndex
         }
 
         // If the table has fields which could contain relations and the record does exist (including deleted-flagged)
-        $queryBuilder = $connection->createQueryBuilder();
+        $queryBuilder = $connectionPool->getQueryBuilderForTable($tableName);
         $queryBuilder->getRestrictions()->removeAll();
 
         $exists = $queryBuilder