#92604Translation of child elements connected to a page record currently broken
Description
This bug had been reported with CMS 8 already but was rejected because it was reported in conjunction with pages_language_overlay, but actually the same problem still exists.
The localize method of the DataHandler does not call the same copy action for pages as it does for any other table, that’s why any record connected via an inline field will not be translated properly.
if ($table !== 'pages') {
// 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, '', $language);
$autoVersionNewId = $this->getAutoVersionId($table, $newId);
if ($autoVersionNewId !== null) {
$this->triggerRemapAction($table, $newId, [$this, 'placeholderShadowing'], [$table, $autoVersionNewId], true);
}
} else {
// Create new page which needs to contain the same pid as the original page
$overrideValues['pid'] = $row['pid'];
// Take over the hidden state of the original language state, this is done due to legacy reasons where-as
// pages_language_overlay was set to "hidden -> default=0" but pages hidden -> default 1"
if (!empty($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) {
$hiddenFieldName = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
$overrideValues[$hiddenFieldName] = $row[$hiddenFieldName] ?? $GLOBALS['TCA'][$table]['columns'][$hiddenFieldName]['config']['default'];
}
$temporaryId = StringUtility::getUniqueId('NEW');
$copyTCE = $this->getLocalTCE();
$copyTCE->start([$table => [$temporaryId => $overrideValues]], [], $this->BE_USER);
$copyTCE->process_datamap();
// Getting the new UID as if it had been copied:
$theNewSQLID = $copyTCE->substNEWwithIDs[$temporaryId];
if ($theNewSQLID) {
$this->copyMappingArray[$table][$uid] = $theNewSQLID;
$newId = $theNewSQLID;
}
Currently this has been kind of hidden by giving i.e. the media field of the pages table an additional behaviour “allowLanguageSynchronization = true”.
But this obviously just replaces the automatic creation of translated children with a manual process of adding new references.
This again contradicts the principles of the “connected mode”, since the child records of translated pages will not get a proper translation parent this way.
Disabling that “allowLanguageSynchronization” behaviour will not create the original core behaviour as it is known from i.e. the tt_content media field, but will just create an empty field value.
Trying the same with the L10nmgr, which actually correctly exports the sys_file_reference will create an additional reference to the default language page record instead of creating a new one in the target language during the import.
Reviews 3
- main 83001[WIP][TASK] Use copy method when localizing pages
- main 83057[TASK] Avoid runtime caching pages in DataHandler
- main 66213[WIP][BUGFIX] Use copy method when localizing pages
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". The changes above were merged or abandoned: read them before you start. How to create a patch
- Commit message
-
[BUGFIX] Translation of child elements connected to a page record currently broken Resolves: #92604 Releases: main
Related issues 2
History 2036
Show 11 earlier messages
-
Jo Hasenau changed description <span data-processor="relativetime" data-value="2020-10-19T20:29:47+00:00" > 10/19/20, 20:29 </span>
-
Jo Hasenau changed description <span data-processor="relativetime" data-value="2020-10-19T20:30:29+00:00" > 10/19/20, 20:30 </span>
-
Jo Hasenau changed Duplicates #78743 <span data-processor="relativetime" data-value="2020-10-19T20:30:53+00:00" > 10/19/20, 20:30 </span>
-
Jo Hasenau changed description <span data-processor="relativetime" data-value="2020-10-19T20:33:58+00:00" > 10/19/20, 20:33 </span>
-
Jo Hasenau changed Duplicates #81346 <span data-processor="relativetime" data-value="2020-10-19T20:46:25+00:00" > 10/19/20, 20:46 </span>
-
Jo Hasenau changed description <span data-processor="relativetime" data-value="2020-10-19T20:50:14+00:00" > 10/19/20, 20:50 </span>
-
Jo Hasenau changed category <span data-processor="relativetime" data-value="2020-10-19T20:58:16+00:00" > 10/19/20, 20:58 </span>
-
Jo Hasenau commented <span data-processor="relativetime" data-value="2020-10-19T21:09:04+00:00" > 10/19/20, 21:09 </span>
A first test with a patched core revealed that the problem can be eliminated by removing the if/else check and treating the table “pages” just as any other translatable table.
All references – in our case the “media” field and another “nav_icon” field of the introduction package – were translated properly. -
Jo Hasenau changed subject
Translation of child elements together with the page record currently brokenTranslation of child elements connected to a page record currently broken <span data-processor="relativetime" data-value="2020-10-20T09:57:00+00:00" > 10/20/20, 09:57 </span> -
Jo Hasenau commented <span data-processor="relativetime" data-value="2020-10-20T10:04:25+00:00" > 10/20/20, 10:04 </span>
BTW: The original check was
if ($Ttable === $table) {}This was only there to have a difference between translations to the same table and translation to a second table, which was the case for pages and tt_products only but never used by anybody else IIRC.
Since this option has been removed and there is no pages_language_overlay anymore, we should have dropped that check completely instead of changing it to
if ($table !== 'pages') {}
-
Benni Mack commented <span data-processor="relativetime" data-value="2020-10-20T21:50:13+00:00" > 10/20/20, 21:50 </span>
pages still do have a special meaning when it comes to translations:- The “pid” needs to be the same (= the parent page ID) (which, I guess should not matter in your case)
- The “sorting” will be the same as the page in default language
Have you removed the if() condition already and checked if all DataHandler tests still work as expected?
-
Jo Hasenau commented <span data-processor="relativetime" data-value="2020-10-21T13:25:16+00:00" > 10/21/20, 13:25 </span>
So we would need some overrideValues to ensure the correct behaviour which should be done in the copyRecord method before calling process_datamap() then.
The “patch” was just an idea and a quick and dirty try – no real tests done on that yet, but will of course be done before pushing a patch to Gerrit.
-
Gerrit Code Review pushed patch set 5 for master to change 66213 status
NewUnder Review <span data-processor="relativetime" data-value="2020-10-28T21:02:25+00:00" > 10/28/20, 21:02 </span> -
Gerrit Code Review pushed patch set 6 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-19T12:03:09+00:00" > 11/19/20, 12:03 </span>
-
Gerrit Code Review pushed patch set 7 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-25T16:31:36+00:00" > 11/25/20, 16:31 </span>
-
Gerrit Code Review pushed patch set 8 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T08:46:50+00:00" > 11/26/20, 08:46 </span>
-
Gerrit Code Review pushed patch set 9 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T10:34:42+00:00" > 11/26/20, 10:34 </span>
-
Gerrit Code Review pushed patch set 10 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T11:44:06+00:00" > 11/26/20, 11:44 </span>
-
Gerrit Code Review pushed patch set 11 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T12:35:59+00:00" > 11/26/20, 12:35 </span>
-
Gerrit Code Review pushed patch set 12 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T15:41:17+00:00" > 11/26/20, 15:41 </span>
-
Gerrit Code Review pushed patch set 13 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T17:04:53+00:00" > 11/26/20, 17:04 </span>
-
Gerrit Code Review pushed patch set 14 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T17:42:46+00:00" > 11/26/20, 17:42 </span>
-
Gerrit Code Review pushed patch set 15 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T17:43:53+00:00" > 11/26/20, 17:43 </span>
-
Gerrit Code Review pushed patch set 16 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T21:04:17+00:00" > 11/26/20, 21:04 </span>
-
Gerrit Code Review pushed patch set 17 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-26T22:16:47+00:00" > 11/26/20, 22:16 </span>
-
Gerrit Code Review pushed patch set 18 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-27T09:05:33+00:00" > 11/27/20, 09:05 </span>
-
Gerrit Code Review pushed patch set 19 for master to change 66213 <span data-processor="relativetime" data-value="2020-11-27T09:54:15+00:00" > 11/27/20, 09:54 </span>
-
Benni Mack changed status
Under ReviewAccepted <span data-processor="relativetime" data-value="2020-12-10T22:39:29+00:00" > 12/10/20, 22:39 </span> -
Christian Kuhn commented and changed status
AcceptedClosed <span data-processor="relativetime" data-value="2024-02-09T14:18:06+00:00" > 02/09/24, 14:18 </span>closed as dupe of #92604 -
Felix Nagel commented <span data-processor="relativetime" data-value="2024-02-09T14:34:12+00:00" > 02/09/24, 14:34 </span>
@lolli Closed as duplicate of itself?
-
Riccardo De Contardi changed status
ClosedAccepted <span data-processor="relativetime" data-value="2024-02-09T14:57:15+00:00" > 02/09/24, 14:57 </span> -
Christian Kuhn commented <span data-processor="relativetime" data-value="2024-02-14T16:43:50+00:00" > 02/14/24, 16:43 </span>
Oops … I of course meant I closed #81346 as dupe of this one ..
-
Gerrit Code Review pushed patch set 5 for main to change 83001 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2024-02-20T13:21:51+00:00" > 02/20/24, 13:21 </span> -
Christian Kuhn changed Related to #79610 <span data-processor="relativetime" data-value="2024-02-21T11:55:00+00:00" > 02/21/24, 11:55 </span>
-
Christian Kuhn changed Related to #103172 <span data-processor="relativetime" data-value="2024-02-21T12:14:34+00:00" > 02/21/24, 12:14 </span>
Especially the broken L10nmgr behaviour points out the actual source of the problem: We’ve only got the process_datamap() call within the localize process for pages, so the call to copyRecord_procBasedOnFieldType, which will be invoked for any other translatable table before calling process_datamap(), is completely missing.
Still process_cmdmap() usually takes care of creating all the necessary copies throughout the whole structure of parent records, children and grandchildren during a “non translation” copy action.
So the L10nmgr just triggers a single translation of the file reference itself and then fills in the translated content, while the “uid_foreign” field will still point to the original parent record of the default language.