[BUGFIX] Avoid excluding fields in copyToLanguage 35/58235/5
authorOliver Hader <oliver@typo3.org>
Sun, 9 Sep 2018 09:17:33 +0000 (11:17 +0200)
committerBenni Mack <benni@typo3.org>
Sat, 27 Oct 2018 14:53:17 +0000 (16:53 +0200)
Given that a TCA column is using 'l10n_mode' => 'exclude' and creating
a "free localization" of that record using DataHandler's copyToLanguage
command, the according field stays empty in the created localization.

The expected behavior is that the accordings field is still duplicated
once on creating the duplicate for a particular language. Title prefix
"[Translate to <language>:]" is expected to be missing here since it
is the result of a copy command instead of a localize command.

Resolves: #86203
Releases: master
Change-Id: Ib9914a8d02cbbabdbdc56720a983b6314a34709b
Reviewed-on: https://review.typo3.org/58235
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: J├╝rgen Heym <juergen.heym@hof-university.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/ActionTest.php
typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/DataSet/copyContentToLanguageWExclude.csv

index 6afc309..05ebd41 100644 (file)
@@ -4900,7 +4900,6 @@ class DataHandler implements LoggerAwareInterface
 
         // Initialize:
         $overrideValues = [];
-        $excludeFields = [];
         // Set override values:
         $overrideValues[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = $langRec['uid'];
         // If the translated record is a default language record, set it's uid as localization parent of the new record.
@@ -4946,14 +4945,6 @@ class DataHandler implements LoggerAwareInterface
                         $overrideValues[$fN] = $row[$fN];
                     }
                 }
-            } elseif (
-                ($fCfg['l10n_mode'] === 'exclude')
-                    && $fN != $GLOBALS['TCA'][$table]['ctrl']['languageField']
-                    && $fN != $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
-            ) {
-                // Otherwise, do not copy field (unless it is the language field or
-                // pointer to the original language)
-                $excludeFields[] = $fN;
             }
         }
 
@@ -4961,7 +4952,7 @@ class DataHandler implements LoggerAwareInterface
             // Get the uid of record after which this localized record should be inserted
             $previousUid = $this->getPreviousLocalizedRecordUid($table, $uid, $row['pid'], $language);
             // Execute the copy:
-            $newId = $this->copyRecord($table, $uid, -$previousUid, true, $overrideValues, implode(',', $excludeFields), $language);
+            $newId = $this->copyRecord($table, $uid, -$previousUid, true, $overrideValues, '', $language);
             $autoVersionNewId = $this->getAutoVersionId($table, $newId);
             if ($autoVersionNewId !== null) {
                 $this->triggerRemapAction($table, $newId, [$this, 'placeholderShadowing'], [$table, $autoVersionNewId], true);
index eb0d656..43110bb 100644 (file)
@@ -166,9 +166,7 @@ class ActionTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\A
         ]);
         $responseSections = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseSections();
         $this->assertThat($responseSections, $this->getRequestSectionHasRecordConstraint()
-            // @todo Currently the behavior is "correct", however might be enhanced in the future with https://review.typo3.org/#/c/58235/
-            // ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #3', '[Translate to Dansk:] Regular Element #2'));
-            ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #3', ''));
+            ->setTable(self::TABLE_Content)->setField('header')->setValues('[Translate to Dansk:] Regular Element #1', '[Translate to Dansk:] Regular Element #3', 'Regular Element #2 (copy 1)'));
     }
 
     /**
index 17bcd2a..9bb03cf 100644 (file)
@@ -7,5 +7,4 @@
 ,300,89,1024,0,1,299,299,299,0,0,0,0,0,"[Translate to Dansk:] Regular Element #3",
 ,301,89,384,0,1,297,297,297,0,0,0,0,0,"[Translate to Dansk:] Regular Element #1",
 ,302,89,448,0,2,297,301,301,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1",
-#,303,89,416,0,1,0,298,298,0,0,0,0,0,"[Translate to Dansk:] Regular Element #2",
-,303,89,416,0,1,0,298,298,0,0,0,0,0,"",
+,303,89,416,0,1,0,298,298,0,0,0,0,0,"Regular Element #2 (copy 1)",