[BUGFIX] Rootline utility must respect pageOverlayFields 96/20796/8
authorStefan Galinski <stefan.galinski@gmail.com>
Wed, 15 May 2013 14:18:05 +0000 (16:18 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 29 Jun 2013 12:07:30 +0000 (14:07 +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/20796
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Utility/RootlineUtility.php

index 0c81546..f191ef8 100644 (file)
@@ -236,6 +236,7 @@ class RootlineUtility {
         * @return array $pageRecord with additional relations
         */
        protected function enrichWithRelationFields($uid, array $pageRecord) {
         * @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'];
                foreach ($GLOBALS['TCA']['pages']['columns'] as $column => $configuration) {
                        if ($this->columnHasRelationToResolve($configuration)) {
                                $configuration = $configuration['config'];
@@ -245,16 +246,17 @@ class RootlineUtility {
                                        $loadDBGroup->start($pageRecord[$column], $configuration['foreign_table'], $configuration['MM'], $uid, 'pages', $configuration);
                                        $relatedUids = $loadDBGroup->tableArray[$configuration['foreign_table']];
                                } else {
                                        $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'];
                                        $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 (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\'';
                                                        $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages_language_overlay\'';
                                                } else {
                                                        $whereClauseParts[] = trim($configuration['foreign_table_field']) . ' = \'pages\'';
@@ -393,4 +395,4 @@ class RootlineUtility {
 }
 
 
 }
 
 
-?>
+?>
\ No newline at end of file