Commit 90d7fd6d authored by Oliver Hader's avatar Oliver Hader Committed by Oliver Hader
Browse files

[BUGFIX] l10n_mode=exclude not properly applied when processing ancestors

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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
parent 10d623a6
......@@ -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;
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment