[BUGFIX] Fix early return in addUnionStatement method 90/51290/5
authorDominique Kreemers <dominique.kreemers@icloud.com>
Tue, 17 Jan 2017 11:19:24 +0000 (12:19 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 25 Jan 2017 04:15:09 +0000 (05:15 +0100)
Set $propertyPath, $tableName and $className to avoid
unnecessary joins and wrong repository results.

This is a regression fix after the Doctrine migration.

Resolves: #79286
Related: #77379
Releases: master
Change-Id: I64489b46b9ca751535b64482f54ceb7b2da05003
Reviewed-on: https://review.typo3.org/51290
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php
typo3/sysext/extbase/Tests/Functional/Persistence/CountTest.php

index 8dc9259..fb90ddb 100644 (file)
@@ -905,8 +905,11 @@ class Typo3DbQueryParser
         $fullPropertyPath .= ($fullPropertyPath === '') ? $propertyName : '.' . $propertyName;
         $childTableAlias = $this->getUniqueAlias($childTableName, $fullPropertyPath);
 
-        // If there is already exists a union with the current identifier we do not need to build it again and exit early.
+        // If there is already a union with the current identifier we do not need to build it again and exit early.
         if (in_array($childTableAlias, $this->unionTableAliasCache, true)) {
+            $propertyPath = $explodedPropertyPath[1];
+            $tableName = $childTableAlias;
+            $className = $this->dataMapper->getType($className, $propertyName);
             return;
         }
 
index 87a5367..79ab879 100644 (file)
@@ -197,7 +197,11 @@ class CountTest extends \TYPO3\CMS\Components\TestingFramework\Core\FunctionalTe
             )
         );
 
-        $this->assertSame(10, $query->count());
+        // QueryResult is lazy, so we have to run valid method to initialize
+        $result = $query->execute();
+        $result->valid();
+
+        $this->assertSame(10, $result->count());
     }
 
     /**