[BUGFIX] Rootline utility must respect pageOverlayFields 23/21723/2
authorStefan Galinski <stefan.galinski@gmail.com>
Wed, 15 May 2013 14:18:05 +0000 (16:18 +0200)
committerStefan Galinski <stefan.galinski@gmail.com>
Thu, 4 Jul 2013 18:09:39 +0000 (20:09 +0200)
The rootline calculation always overlays all fields
from the pages table. This causes trouble in e.g. the
case that you want to reuse media images from the default
language in other languages. In the previous implementation
(pre 6.x) only the overlay fields from the
 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']
setting were overlaid.

Fixes: #48224
Releases: 6.2, 6.1, 6.0
Change-Id: I6f5a10150c916df24542ee83e33663a27bdb593f
Reviewed-on: https://review.typo3.org/21723
Reviewed-by: Stefan Galinski
Tested-by: Stefan Galinski
typo3/sysext/core/Classes/Utility/RootlineUtility.php

index 3828f63..35579ab 100644 (file)
@@ -241,6 +241,7 @@ class RootlineUtility {
         * @return array $pageRecord with additional relations
         */
        protected function enrichWithRelationFields($uid, array $pageRecord) {
+               $pageOverlayFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
                foreach ($GLOBALS['TCA']['pages']['columns'] as $column => $configuration) {
                        if ($this->columnHasRelationToResolve($configuration)) {
                                $configuration = $configuration['config'];
@@ -250,16 +251,17 @@ class RootlineUtility {
                                        $loadDBGroup->start($pageRecord[$column], $configuration['foreign_table'], $configuration['MM'], $uid, 'pages', $configuration);
                                        $relatedUids = $loadDBGroup->tableArray[$configuration['foreign_table']];
                                } else {
+                                       $columnIsOverlaid = in_array($column, $pageOverlayFields, TRUE);
                                        $table = $configuration['foreign_table'];
                                        $field = $configuration['foreign_field'];
-                                       $whereClauseParts = array($field . ' = ' . intval($uid));
+                                       $whereClauseParts = array($field . ' = ' . intval($columnIsOverlaid ? $uid : $pageRecord['uid']));
                                        if (isset($configuration['foreign_match_fields']) && is_array($configuration['foreign_match_fields'])) {
                                                foreach ($configuration['foreign_match_fields'] as $field => $value) {
                                                        $whereClauseParts[] = $field . ' = ' . $this->databaseConnection->fullQuoteStr($value, $table);
                                                }
                                        }
                                        if (isset($configuration['foreign_table_field'])) {
-                                               if (intval($this->languageUid) > 0) {
+                                               if (intval($this->languageUid) > 0 && $columnIsOverlaid) {
                                                        $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages_language_overlay\'';
                                                } else {
                                                        $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages\'';