[BUGFIX] l10n_mode=exclude not properly applied when processing ancestors 33/52333/5
authorOliver Hader <oliver@typo3.org>
Mon, 3 Apr 2017 10:58:26 +0000 (12:58 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 3 Apr 2017 16:27:56 +0000 (18:27 +0200)
Fields using l10n_mode=exclude are not properly populated if any ancestor
record is updated.

Change-Id: I0a132191caaac7fbd3642f8a1bc88bb263a127af
Resolves: #80656
Releases: master
Reviewed-on: https://review.typo3.org/52333
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/DataHandling/Localization/DataMapProcessor.php
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/Modify/DataSet/localizeNCopyPageWSynchronization.csv
typo3/sysext/core/Tests/Functional/DataHandling/IRRE/ForeignField/Modify/DataSet/localizePageNAddHotelChildWExclude.csv
typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts

index ecb3f74..f58595c 100644 (file)
@@ -4780,12 +4780,12 @@ class DataHandler
             }
         } else {
             // Create new record:
-            /** @var $copyTCE DataHandler */
+            $temporaryId = StringUtility::getUniqueId('NEW');
             $copyTCE = $this->getLocalTCE();
-            $copyTCE->start([$Ttable => ['NEW' => $overrideValues]], '', $this->BE_USER);
+            $copyTCE->start([$Ttable => [$temporaryId => $overrideValues]], [], $this->BE_USER);
             $copyTCE->process_datamap();
             // Getting the new UID as if it had been copied:
-            $theNewSQLID = $copyTCE->substNEWwithIDs['NEW'];
+            $theNewSQLID = $copyTCE->substNEWwithIDs[$temporaryId];
             if ($theNewSQLID) {
                 // If is by design that $Ttable is used and not $table! See "l10nmgr" extension. Could be debated, but this is what I chose for this "pseudo case"
                 $this->copyMappingArray[$Ttable][$uid] = $theNewSQLID;
index 684185d..bf7204c 100644 (file)
@@ -330,7 +330,7 @@ class DataMapProcessor
             return;
         }
 
-        foreach ([State::STATE_PARENT, State::STATE_SOURCE] as $scope) {
+        foreach ([DataMapItem::SCOPE_PARENT, DataMapItem::SCOPE_SOURCE] as $scope) {
             foreach ($item->findDependencies($scope) as $dependentItem) {
                 // use suggested item, if it was submitted in data-map
                 $suggestedDependentItem = $this->findItem(
@@ -340,16 +340,18 @@ class DataMapProcessor
                 if ($suggestedDependentItem !== null) {
                     $dependentItem = $suggestedDependentItem;
                 }
-                $fieldNames = $this->getFieldNamesForItemScope(
-                    $dependentItem,
-                    $scope,
-                    false
-                );
-                $this->synchronizeTranslationItem(
-                    $dependentItem,
-                    $fieldNames,
-                    $item->getId()
-                );
+                foreach ([$scope, DataMapItem::SCOPE_EXCLUDE] as $dependentScope) {
+                    $fieldNames = $this->getFieldNamesForItemScope(
+                        $dependentItem,
+                        $dependentScope,
+                        false
+                    );
+                    $this->synchronizeTranslationItem(
+                        $dependentItem,
+                        $fieldNames,
+                        $item->getId()
+                    );
+                }
             }
         }
     }
@@ -575,8 +577,8 @@ class DataMapProcessor
         // Otherwise child relations would superfluously be duplicated again here.
         // @todo Invalid manually injected child relations cannot be determined here
         $sanitizedValue = $this->sanitizationMap[$item->getTableName()][$item->getId()][$fieldName] ?? null;
-        if (!empty($missingAncestorIds) && $item->isNew()
-            && $sanitizedValue !== null && !$isTranslatable
+        if (
+            !empty($missingAncestorIds) && $item->isNew() && $sanitizedValue !== null
             && count(GeneralUtility::trimExplode(',', $sanitizedValue)) === count($missingAncestorIds)
         ) {
             $this->modifyDataMap(
@@ -639,7 +641,8 @@ class DataMapProcessor
                         $foreignTableName,
                         $populateAncestorId,
                         $item->getLanguage(),
-                        $fieldNames
+                        $fieldNames,
+                        !$isLocalizationModeExclude && $isTranslatable
                     )
                 );
             }
@@ -1130,14 +1133,14 @@ class DataMapProcessor
      * @param string|int $fromId
      * @param int $language
      * @param array $fieldNames
+     * @param bool $localize
      * @return array
      */
-    protected function duplicateFromDataMap(string $tableName, $fromId, int $language, array $fieldNames)
+    protected function duplicateFromDataMap(string $tableName, $fromId, int $language, array $fieldNames, bool $localize)
     {
         $data = $this->allDataMap[$tableName][$fromId];
-        $isTranslatable = (!empty($fieldNames['language']) && !empty($fieldNames['parent']));
-
-        if (empty($language) || !$isTranslatable) {
+        // just return duplicated item if localization cannot be applied
+        if (empty($language) || !$localize) {
             return $data;
         }
 
index d7647fb..f14a188 100644 (file)
@@ -24,20 +24,19 @@ tx_irretutorial_1nff_hotel
 ,6,89,1,0,1,2,2,0,0,0,0,0,"[Translate to Dansk:] Hotel #0",1,pages_language_overlay,,0
 ,7,91,1,0,0,0,2,0,0,0,0,0,"Hotel #0",91,pages,,0
 ,8,91,1,0,1,7,6,0,0,0,0,0,"[Translate to Dansk:] Hotel #0",2,pages_language_overlay,,0
-,9,90,1,0,1,7,7,0,0,0,0,0,"[Translate to Dansk:] Hotel #0",2,pages_language_overlay,,0
-,10,91,1,0,0,0,5,0,0,0,0,0,"Hotel #1",299,tt_content,,1
-,11,91,1,0,0,0,3,0,0,0,0,0,"Hotel #1",300,tt_content,,2
-,12,91,2,0,0,0,4,0,0,0,0,0,"Hotel #2",300,tt_content,,1
+,9,91,1,0,0,0,5,0,0,0,0,0,"Hotel #1",299,tt_content,,1
+,10,91,1,0,0,0,3,0,0,0,0,0,"Hotel #1",300,tt_content,,2
+,11,91,2,0,0,0,4,0,0,0,0,0,"Hotel #2",300,tt_content,,1
 tx_irretutorial_1nff_offer
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,prices
 ,5,89,1,0,0,0,0,0,0,0,0,0,"Offer #1.1",3,tx_irretutorial_1nff_hotel,,3
 ,6,89,2,0,0,0,0,0,0,0,0,0,"Offer #1.2",3,tx_irretutorial_1nff_hotel,,2
 ,7,89,1,0,0,0,0,0,0,0,0,0,"Offer #2.1",4,tx_irretutorial_1nff_hotel,,1
 ,8,89,1,0,0,0,0,0,0,0,0,0,"Offer #1.1",5,tx_irretutorial_1nff_hotel,,1
-,9,91,1,0,0,0,8,0,0,0,0,0,"Offer #1.1",10,tx_irretutorial_1nff_hotel,,1
-,10,91,1,0,0,0,5,0,0,0,0,0,"Offer #1.1",11,tx_irretutorial_1nff_hotel,,3
-,11,91,2,0,0,0,6,0,0,0,0,0,"Offer #1.2",11,tx_irretutorial_1nff_hotel,,2
-,12,91,1,0,0,0,7,0,0,0,0,0,"Offer #2.1",12,tx_irretutorial_1nff_hotel,,1
+,9,91,1,0,0,0,8,0,0,0,0,0,"Offer #1.1",9,tx_irretutorial_1nff_hotel,,1
+,10,91,1,0,0,0,5,0,0,0,0,0,"Offer #1.1",10,tx_irretutorial_1nff_hotel,,3
+,11,91,2,0,0,0,6,0,0,0,0,0,"Offer #1.2",10,tx_irretutorial_1nff_hotel,,2
+,12,91,1,0,0,0,7,0,0,0,0,0,"Offer #2.1",11,tx_irretutorial_1nff_hotel,,1
 tx_irretutorial_1nff_price
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier
 ,7,89,1,0,0,0,0,0,0,0,0,0,"Price #1.1.1",5,tx_irretutorial_1nff_offer,
index 376ecdc..3024461 100644 (file)
@@ -6,7 +6,7 @@ pages
 ,90,88,512,0,0,0,0,0,0,0,Target,0
 pages_language_overlay
 ,uid,pid,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,title,tx_irretutorial_hotels,l10n_state
-,1,89,0,1,0,0,0,0,"[Translate to Dansk:] Relations",1,
+,1,89,0,1,0,0,0,0,"[Translate to Dansk:] Relations",2,
 tt_content
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,tx_irretutorial_1nff_hotels
 ,297,89,256,0,0,0,0,0,0,0,0,0,"Regular Element #1",2
@@ -17,8 +17,10 @@ tx_irretutorial_1nff_hotel
 ,3,89,1024,0,0,0,0,0,0,0,0,0,"Hotel #1",297,tt_content,,2
 ,4,89,1536,0,0,0,0,0,0,0,0,0,"Hotel #2",297,tt_content,,1
 ,5,89,1280,0,0,0,0,0,0,0,0,0,"Hotel #1",298,tt_content,,1
-,6,89,1,0,0,0,2,0,0,0,0,0,"Hotel #0",1,pages_language_overlay,,0
-,7,89,2,0,0,0,0,0,0,0,0,0,"Hotel #007",89,pages,,0
+,6,89,1000000000,1,0,0,2,0,0,0,0,0,"Hotel #0",1,pages_language_overlay,,0
+,7,89,1,0,0,0,2,0,0,0,0,0,"Hotel #0",1,pages_language_overlay,,0
+,8,89,2,0,0,0,0,0,0,0,0,0,"Hotel #007",89,pages,,0
+,9,89,2,0,0,0,0,0,0,0,0,0,"Hotel #007",1,pages_language_overlay,,0
 tx_irretutorial_1nff_offer
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3_origuid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,prices
 ,5,89,1,0,0,0,0,0,0,0,0,0,"Offer #1.1",3,tx_irretutorial_1nff_hotel,,3
index f007c83..b465ae6 100644 (file)
@@ -12,7 +12,7 @@ config {
 
        watcher {
                tableFields {
-                       pages = uid,_ORIG_uid,pid,sorting,title,tx_irretutorial_hotels
+                       pages = uid,_PAGES_OVERLAY_UID,pid,sorting,title,tx_irretutorial_hotels
                        sys_category = uid,_ORIG_uid,_LOCALIZED_UID,pid,sys_language_uid,title,parent,items,sys_language_uid
                        sys_file = uid,_ORIG_uid,_LOCALIZED_UID,pid,title,sys_language_uid
                        sys_file_reference = uid,_ORIG_uid,_LOCALIZED_UID,title,description,alternative,link,missing,identifier,file,pid,sys_language_uid,title,parent,items,sys_language_uid,uid_local,uid_foreign,tablenames,fieldname,table_local
@@ -67,19 +67,19 @@ page {
                        renderObj < lib.watcherDataObject
                        renderObj.1.watcher.dataWrap = {register:watcher}|.__pages/pages:{field:uid}
                }
-        15 = CONTENT
-        15 {
-            if.isTrue.field = tx_irretutorial_hotels
-            table = tx_irretutorial_1nff_hotel
-            select {
-                orderBy = sorting
-                where.field = uid
-                where.intval = 1
-                where.wrap = parenttable='pages' AND parentid=|
-            }
-            renderObj < lib.watcherDataObject
-            renderObj.1.watcher.dataWrap = {register:watcher}|.tx_irretutorial_hotels/tx_irretutorial_1nff_hotel:{field:uid}
-        }
+               15 = CONTENT
+               15 {
+                       if.isTrue.field = tx_irretutorial_hotels
+                       table = tx_irretutorial_1nff_hotel
+                       select {
+                               orderBy = sorting
+                               where.field = uid
+                               where.intval = 1
+                               where.wrap = parenttable='pages' AND parentid=|
+                       }
+                       renderObj < lib.watcherDataObject
+                       renderObj.1.watcher.dataWrap = {register:watcher}|.tx_irretutorial_hotels/tx_irretutorial_1nff_hotel:{field:uid}
+               }
                20 = CONTENT
                20 {
                        table = tt_content