[BUGFIX] MM relations are not correctly resolved in Backend view 37/30037/2
authorOliver Hader <oliver@typo3.org>
Tue, 13 May 2014 08:19:58 +0000 (10:19 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 13 May 2014 16:03:43 +0000 (18:03 +0200)
DataPreprocessor is taking care of preparing data for the form
view processed in the FormEngine. However, MM relations are not
correctly resolved in a workspace context.

The method DataPreprocessor::getDataIdList() is used for a mixed
kind of relations there, without properly applying the differences
for MM records. The rule is, to always use the live default id,
except for MM relations - use the specific workspace value.

Resolves: #58735
Releases: 6.2
Change-Id: I256969adb46bfea80681160e2901387a8c7c9a7d
Reviewed-on: https://review.typo3.org/30037
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Markus Klein
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/backend/Classes/Form/DataPreprocessor.php

index effe8a5..180702c 100644 (file)
@@ -815,10 +815,15 @@ class DataPreprocessor {
         * @todo Define visibility
         */
        public function getDataIdList($elements, $fieldConfig, $row, $table) {
-               $liveDefaultId = $this->getLiveDefaultId($table, $row['uid']);
+               // Use given uid (might be the uid of a workspace record)
+               $recordId = $row['uid'];
+               // If not dealing with MM relations, then always(!) use the default live uid
+               if (empty($fieldConfig['config']['MM'])) {
+                       $recordId = $this->getLiveDefaultId($table, $row['uid']);
+               }
                $loadDB = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler');
                $loadDB->registerNonTableValues = $fieldConfig['config']['allowNonIdValues'] ? 1 : 0;
-               $loadDB->start(implode(',', $elements), $fieldConfig['config']['foreign_table'] . ',' . $fieldConfig['config']['neg_foreign_table'], $fieldConfig['config']['MM'], $liveDefaultId, $table, $fieldConfig['config']);
+               $loadDB->start(implode(',', $elements), $fieldConfig['config']['foreign_table'] . ',' . $fieldConfig['config']['neg_foreign_table'], $fieldConfig['config']['MM'], $recordId, $table, $fieldConfig['config']);
                $idList = $loadDB->convertPosNeg($loadDB->getValueArray(), $fieldConfig['config']['foreign_table'], $fieldConfig['config']['neg_foreign_table']);
                return $idList;
        }