Commit 1b8efb4b authored by Nicole Cordes's avatar Nicole Cordes Committed by Oliver Hader
Browse files

[BUGFIX] Return correct source record for relations

This change addresses a flaw when resolving ancestor ids of 1:n
relationships - resolving `l10n_source` pointer always was `0`.

Besides that now only non-empty `l10n_parent` or `l10n_source` are
returned as integer. Otherwise `null` is returned and signals that
a corresponding ancestor could not be resolved at all.

Scenario `localizeParentContentChainLanguageSynchronizationSource` of
`DataHandling\IRRE\ForeignField\Modify\ActionTest` was given already,
however `l10n_source` fields were missing in their TCA.

Resolves: #86141
Releases: master, 10.4, 9.5
Change-Id: Ia0e3d9accd5c1998f4fd971861262c158cc8f838
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69031

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
parent 9b83ac66
......@@ -1019,7 +1019,7 @@ class DataMapProcessor
continue;
}
// only keep ancestors that were initially requested before expanding
if (in_array($ancestorId, $ids)) {
if (in_array($ancestorId, $ids, true)) {
$dependentIdMap[$ancestorId] = $dependentId;
} elseif (!empty($ancestorIdMap[$ancestorId])) {
// resolve from previously expanded search criteria
......@@ -1138,16 +1138,17 @@ class DataMapProcessor
* Return only ids that are integer - so no "NEW..." values
*
* @param string[]|int[] $ids
* @return int[]|string[]
* @return int[]
*/
protected function filterNumericIds(array $ids)
{
return array_filter(
$ids = array_filter(
$ids,
function ($id) {
return MathUtility::canBeInterpretedAsInteger($id);
}
);
return array_map('intval', $ids);
}
/**
......@@ -1184,22 +1185,21 @@ class DataMapProcessor
}
/**
* @param array $fieldNames
* @param array $element
* @return int|null
* @param array<string, string> $fieldNames
* @param array<string, mixed> $element
* @return int|null either a (non-empty) ancestor uid, or `null` if unresolved
*/
protected function resolveAncestorId(array $fieldNames, array $element)
{
// implicit: having source value different to parent value, use source pointer
if (
!empty($fieldNames['source'])
&& $element[$fieldNames['source']] !== $element[$fieldNames['parent']]
) {
return (int)$fieldNames['source'];
}
if (!empty($fieldNames['parent'])) {
// implicit: use parent pointer if defined
return (int)$element[$fieldNames['parent']];
$sourceName = $fieldNames['source'] ?? null;
if ($sourceName !== null && !empty($element[$sourceName])) {
// implicit: use source pointer if given (not empty)
return (int)$element[$sourceName];
}
$parentName = $fieldNames['parent'] ?? null;
if ($parentName !== null && !empty($element[$parentName])) {
// implicit: use parent pointer if given (not empty)
return (int)$element[$parentName];
}
return null;
}
......
"tt_content",,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","header","tx_irretutorial_1nff_hotels","l10n_state",
,297,89,256,0,0,0,0,0,0,0,0,0,0,"Regular Element #1",2,,
,298,89,512,0,0,0,0,0,0,0,0,0,0,"Regular Element #2",2,,
,299,89,768,0,1,298,298,298,0,0,0,0,0,"[Translate to Dansk:] Regular Element #2",2,"{""tx_irretutorial_1nff_hotels"":""parent""}",
,300,89,1024,0,2,298,299,299,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #2",2,"{""tx_irretutorial_1nff_hotels"":""source""}",
"tx_irretutorial_1nff_hotel",,,,,,,,,,,,,,,,,
,"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","offers"
,2,89,513,0,0,0,0,0,0,0,0,0,"Hotel #0",89,"pages",,0
,3,89,513,0,0,0,0,0,0,0,0,0,"Hotel #1",297,"tt_content",,2
,4,89,1538,0,0,0,0,0,0,0,0,0,"Hotel #2",297,"tt_content",,1
,5,89,1,0,0,0,0,0,0,0,0,0,"Hotel #1",298,"tt_content",,1
,6,89,1,0,1,5,5,0,0,0,0,0,"[Translate to Dansk:] Hotel #1",299,"tt_content",,1
,7,89,1,0,2,5,6,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Hotel #1",300,"tt_content",,1
,8,89,2,0,0,0,0,0,0,0,0,0,"Hotel #2",298,"tt_content",,0
,9,89,2,0,1,8,0,0,0,0,0,0,"[Translate to Dansk:] Hotel #2",299,"tt_content",,0
,10,89,2,0,2,8,0,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Hotel #2",300,"tt_content",,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
,6,89,1026,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,89,1,0,1,8,8,0,0,0,0,0,"[Translate to Dansk:] Offer #1.1",6,"tx_irretutorial_1nff_hotel",,1
,10,89,1,0,2,8,9,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Offer #1.1",7,"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",,
,8,89,1026,0,0,0,0,0,0,0,0,0,"Price #1.1.2",5,"tx_irretutorial_1nff_offer",,
,9,89,1027,0,0,0,0,0,0,0,0,0,"Price #1.1.3",5,"tx_irretutorial_1nff_offer",,
,10,89,1,0,0,0,0,0,0,0,0,0,"Price #1.2.1",6,"tx_irretutorial_1nff_offer",,
,11,89,1026,0,0,0,0,0,0,0,0,0,"Price #1.2.2",6,"tx_irretutorial_1nff_offer",,
,12,89,1,0,0,0,0,0,0,0,0,0,"Price #2.1.1",7,"tx_irretutorial_1nff_offer",,
,13,89,1,0,0,0,0,0,0,0,0,0,"Price #1.1.1",8,"tx_irretutorial_1nff_offer",,
,14,89,1,0,1,13,13,0,0,0,0,0,"[Translate to Dansk:] Price #1.1.1",9,"tx_irretutorial_1nff_offer",,
,15,89,1,0,2,13,14,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Price #1.1.1",10,"tx_irretutorial_1nff_offer",,
"tt_content",,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","header","tx_irretutorial_1nff_hotels","l10n_state",,
,297,89,256,0,0,0,0,0,0,0,0,0,0,"Regular Element #1",2,,,
,298,89,512,0,0,0,0,0,0,0,0,0,0,"Regular Element #2",2,,,
,299,89,768,0,1,298,298,298,0,0,0,0,0,"[Translate to Dansk:] Regular Element #2",2,"{""tx_irretutorial_1nff_hotels"":""parent""}",,
,300,89,1024,0,2,298,299,299,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Regular Element #2",2,"{""tx_irretutorial_1nff_hotels"":""source""}",,
"tx_irretutorial_1nff_hotel",,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","parentid","parenttable","parentidentifier","offers"
,2,89,513,0,0,0,0,0,0,0,0,0,0,"Hotel #0",89,"pages",,0
,3,89,513,0,0,0,0,0,0,0,0,0,0,"Hotel #1",297,"tt_content",,2
,4,89,1538,0,0,0,0,0,0,0,0,0,0,"Hotel #2",297,"tt_content",,1
,5,89,1,0,0,0,0,0,0,0,0,0,0,"Hotel #1",298,"tt_content",,1
,6,89,1,0,1,5,5,5,0,0,0,0,0,"[Translate to Dansk:] Hotel #1",299,"tt_content",,1
,7,89,1,0,2,5,6,6,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Hotel #1",300,"tt_content",,1
,8,89,2,0,0,0,0,0,0,0,0,0,0,"Hotel #2",298,"tt_content",,0
,9,89,2,0,1,8,8,0,0,0,0,0,0,"[Translate to Dansk:] Hotel #2",299,"tt_content",,0
,10,89,2,0,2,8,8,0,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Hotel #2",300,"tt_content",,0
"tx_irretutorial_1nff_offer",,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","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,0,"Offer #1.1",3,"tx_irretutorial_1nff_hotel",,3
,6,89,1026,0,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,0,"Offer #2.1",4,"tx_irretutorial_1nff_hotel",,1
,8,89,1,0,0,0,0,0,0,0,0,0,0,"Offer #1.1",5,"tx_irretutorial_1nff_hotel",,1
,9,89,1,0,1,8,8,8,0,0,0,0,0,"[Translate to Dansk:] Offer #1.1",6,"tx_irretutorial_1nff_hotel",,1
,10,89,1,0,2,8,9,9,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Offer #1.1",7,"tx_irretutorial_1nff_hotel",,1
"tx_irretutorial_1nff_price",,,,,,,,,,,,,,,,,,
,"uid","pid","sorting","deleted","sys_language_uid","l18n_parent","l10n_source","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,0,"Price #1.1.1",5,"tx_irretutorial_1nff_offer",,
,8,89,1026,0,0,0,0,0,0,0,0,0,0,"Price #1.1.2",5,"tx_irretutorial_1nff_offer",,
,9,89,1027,0,0,0,0,0,0,0,0,0,0,"Price #1.1.3",5,"tx_irretutorial_1nff_offer",,
,10,89,1,0,0,0,0,0,0,0,0,0,0,"Price #1.2.1",6,"tx_irretutorial_1nff_offer",,
,11,89,1026,0,0,0,0,0,0,0,0,0,0,"Price #1.2.2",6,"tx_irretutorial_1nff_offer",,
,12,89,1,0,0,0,0,0,0,0,0,0,0,"Price #2.1.1",7,"tx_irretutorial_1nff_offer",,
,13,89,1,0,0,0,0,0,0,0,0,0,0,"Price #1.1.1",8,"tx_irretutorial_1nff_offer",,
,14,89,1,0,1,13,13,13,0,0,0,0,0,"[Translate to Dansk:] Price #1.1.1",9,"tx_irretutorial_1nff_offer",,
,15,89,1,0,2,13,14,14,0,0,0,0,0,"[Translate to Deutsch:] [Translate to Dansk:] Price #1.1.1",10,"tx_irretutorial_1nff_offer",,
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => [
......
......@@ -9,6 +9,7 @@ return [
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'translationSource' => 'l10n_source',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
......
Markdown is supported
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