[BUGFIX] Prevent ambiguous column name for TCA items 29/62929/4
authorDaniel Siepmann <daniel.siepmann@typo3.org>
Thu, 16 Jan 2020 10:26:03 +0000 (11:26 +0100)
committerTobi Kretschmann <tobi@tobishome.de>
Thu, 16 Jan 2020 12:07:29 +0000 (13:07 +0100)
When fetching items from foreign table, they might be sorted based on
foreign table configured sorting. In such case the foreign table name is
prefixed to prevent ambiguous column name.

Resolves: #90127
Related: #70677
Releases: master, 9.5
Change-Id: Iebda2bd417481ae01b1265dd9be31b67af89991d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62929
Reviewed-by: Felix P. <f.pachowsky@neusta.de>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/AbstractItemProvider.php

index b2fedd1..44d41b1 100644 (file)
@@ -1008,7 +1008,7 @@ abstract class AbstractItemProvider
             $orderByClauses = QueryHelper::parseOrderBy($GLOBALS['TCA'][$foreignTableName]['ctrl']['default_sortby']);
             foreach ($orderByClauses as $orderByClause) {
                 if (!empty($orderByClause[0])) {
-                    $queryBuilder->addOrderBy($orderByClause[0], $orderByClause[1]);
+                    $queryBuilder->addOrderBy($foreignTableName . '.' . $orderByClause[0], $orderByClause[1]);
                 }
             }
         }