[BUGFIX] Fix SQL error for single table view in list module 21/51721/3
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 16 Feb 2017 17:01:33 +0000 (18:01 +0100)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Thu, 16 Feb 2017 23:17:24 +0000 (00:17 +0100)
This patch fixes wrong field escaping due to simple implode of fields
in case label_alt is set for select or groups fields.

Resolves: #79860
Releases: master
Change-Id: Ie0753957e387c1624824d152ac291524cfd34ccd
Reviewed-on: https://review.typo3.org/51721
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index cd57fbf..9ca1850 100644 (file)
@@ -2274,13 +2274,13 @@ class BackendUtility
                     if ($uid) {
                         // Display the title of MM related records in lists
                         if ($noRecordLookup) {
-                            $MMfield = $theColConf['foreign_table'] . '.uid';
+                            $MMfields = [];
+                            $MMfields[] = $theColConf['foreign_table'] . '.uid';
                         } else {
                             $MMfields = [$theColConf['foreign_table'] . '.' . $GLOBALS['TCA'][$theColConf['foreign_table']]['ctrl']['label']];
                             foreach (GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$theColConf['foreign_table']]['ctrl']['label_alt'], true) as $f) {
                                 $MMfields[] = $theColConf['foreign_table'] . '.' . $f;
                             }
-                            $MMfield = implode(',', $MMfields);
                         }
                         /** @var $dbGroup RelationHandler */
                         $dbGroup = GeneralUtility::makeInstance(RelationHandler::class);
@@ -2300,7 +2300,7 @@ class BackendUtility
                                 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
 
                             $result = $queryBuilder
-                                ->select('uid', $MMfield)
+                                ->select('uid', ...$MMfields)
                                 ->from($theColConf['foreign_table'])
                                 ->where(
                                     $queryBuilder->expr()->in(
@@ -2423,7 +2423,8 @@ class BackendUtility
                         if ($uid) {
                             // Display the title of MM related records in lists
                             if ($noRecordLookup) {
-                                $MMfield = $theColConf['foreign_table'] . '.uid';
+                                $MMfields = [];
+                                $MMfields[] = $theColConf['foreign_table'] . '.uid';
                             } else {
                                 $MMfields = [$theColConf['foreign_table'] . '.' . $GLOBALS['TCA'][$theColConf['foreign_table']]['ctrl']['label']];
                                 $altLabelFields = explode(
@@ -2436,7 +2437,6 @@ class BackendUtility
                                         $MMfields[] = $theColConf['foreign_table'] . '.' . $f;
                                     }
                                 }
-                                $MMfield = implode(',', $MMfields);
                             }
                             /** @var $dbGroup RelationHandler */
                             $dbGroup = GeneralUtility::makeInstance(RelationHandler::class);
@@ -2456,7 +2456,7 @@ class BackendUtility
                                     ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
 
                                 $result = $queryBuilder
-                                    ->select('uid', $MMfield)
+                                    ->select('uid', ...$MMfields)
                                     ->from($theColConf['foreign_table'])
                                     ->where(
                                         $queryBuilder->expr()->in(