[BUGFIX] Fix foreign_table_where GROUP BY handling 05/54505/2
authorWolfgang Klinger <wolfgang@wazum.com>
Wed, 25 Oct 2017 10:39:31 +0000 (12:39 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 30 Oct 2017 20:20:24 +0000 (21:20 +0100)
Unpack the array elements before passing them on

Resolves: #82159
Releases: master, 8.7
Change-Id: I6a094927f595d42fc15bb96a9dbc1d313a7808b0
Reviewed-on: https://review.typo3.org/54505
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php

index 92bc5ad..8bfc949 100644 (file)
@@ -961,6 +961,7 @@ abstract class AbstractItemProvider
         $foreignTableClauseArray = $this->processForeignTableClause($result, $foreignTableName, $localFieldName);
 
         $fieldList = BackendUtility::getCommonSelectFields($foreignTableName, $foreignTableName . '.');
+        /** @var QueryBuilder $queryBuilder */
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getQueryBuilderForTable($foreignTableName);
 
@@ -974,7 +975,7 @@ abstract class AbstractItemProvider
             ->where($foreignTableClauseArray['WHERE']);
 
         if (!empty($foreignTableClauseArray['GROUPBY'])) {
-            $queryBuilder->groupBy($foreignTableClauseArray['GROUPBY']);
+            $queryBuilder->groupBy(...$foreignTableClauseArray['GROUPBY']);
         }
 
         if (!empty($foreignTableClauseArray['ORDERBY'])) {
index 52cedf3..8724693 100644 (file)
@@ -1799,7 +1799,7 @@ class TcaSelectItemsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                             'foreign_table' => 'fTable',
                             'foreign_table_where' => '
                                 AND ftable.uid=1
-                                GROUP BY groupField
+                                GROUP BY groupField1, groupField2
                                 ORDER BY orderField
                                 LIMIT 1,2',
                         ],
@@ -1824,7 +1824,7 @@ class TcaSelectItemsTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $queryBuilderProphet->select('fTable.uid')->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
         $queryBuilderProphet->from('fTable')->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
         $queryBuilderProphet->from('pages')->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
-        $queryBuilderProphet->groupBy(['groupField'])->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
+        $queryBuilderProphet->groupBy('groupField1', 'groupField2')->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
         $queryBuilderProphet->addOrderBy('orderField', null)->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
         $queryBuilderProphet->setFirstResult(1)->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());
         $queryBuilderProphet->setMaxResults(2)->shouldBeCalled()->willReturn($queryBuilderProphet->reveal());