From f3e7a034c129aafc8b081e0125c50330207fae82 Mon Sep 17 00:00:00 2001 From: Wolfgang Klinger <wolfgang@wazum.com> Date: Wed, 25 Oct 2017 12:39:31 +0200 Subject: [PATCH] [BUGFIX] Fix foreign_table_where GROUP BY handling Unpack the array elements before passing them on Resolves: #82159 Releases: master, 8.7 Change-Id: I6a094927f595d42fc15bb96a9dbc1d313a7808b0 Reviewed-on: https://review.typo3.org/54473 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> --- .../Classes/Form/FormDataProvider/AbstractItemProvider.php | 3 ++- .../Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php index 5d45a1270c62..1a96445b11d5 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php @@ -943,6 +943,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); @@ -956,7 +957,7 @@ abstract class AbstractItemProvider ->where($foreignTableClauseArray['WHERE']); if (!empty($foreignTableClauseArray['GROUPBY'])) { - $queryBuilder->groupBy($foreignTableClauseArray['GROUPBY']); + $queryBuilder->groupBy(...$foreignTableClauseArray['GROUPBY']); } if (!empty($foreignTableClauseArray['ORDERBY'])) { diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php index b577626a224b..feba4515c43c 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php @@ -1754,7 +1754,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', ], @@ -1779,7 +1779,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()); -- GitLab