[BUGFIX] Use correct parameters for trimExplode 40/54640/3
authorWouter Wolters <typo3@wouterwolters.nl>
Tue, 14 Nov 2017 18:05:15 +0000 (19:05 +0100)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 16 Nov 2017 10:35:59 +0000 (11:35 +0100)
In QueryBuilder::quoteIdentifiersForSelect the 3rd parameter of
trimExplode is inserted. To prevent notices array_pad is added.

Resolves: #82995
Releases: master,8.7
Change-Id: If35efcf5c8c3fd5b0360ae8795f9b92ae87250ab
Reviewed-on: https://review.typo3.org/54640
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/core/Classes/Database/Query/QueryBuilder.php

index 0d01304..45db0f8 100644 (file)
@@ -969,7 +969,16 @@ class QueryBuilder
     public function quoteIdentifiersForSelect(array $input): array
     {
         foreach ($input as &$select) {
-            list($fieldName, $alias, $suffix) = GeneralUtility::trimExplode(' AS ', str_ireplace(' as ', ' AS ', $select), 3);
+            list($fieldName, $alias, $suffix) = array_pad(
+                GeneralUtility::trimExplode(
+                    ' AS ',
+                    str_ireplace(' as ', ' AS ', $select),
+                    true,
+                    3
+                ),
+                3,
+                null
+            );
             if (!empty($suffix)) {
                 throw new \InvalidArgumentException(
                     'QueryBuilder::quoteIdentifiersForSelect() could not parse the input "' . $input . '"',