Issue Bug Under Review Orphaned

#92604Translation of child elements connected to a page record currently broken

Jo Hasenau 10/19/20, 20:29 updated 02/20/24, 13:21

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

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

History 2036

Show 11 earlier messages
  1. Jo Hasenau commented <span data-processor="relativetime" data-value="2020-10-19T20:56:13+00:00" > 10/19/20, 20:56 </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.

  2. 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.

  3. Jo Hasenau changed subject Translation of child elements together with the page record currently broken Translation 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>

  4. 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') {}
  1. 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?

  2. 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.

  3. Gerrit Code Review pushed patch set 5 for master to change 66213 status New Under Review <span data-processor="relativetime" data-value="2020-10-28T21:02:25+00:00" > 10/28/20, 21:02 </span>

  4. Christian Kuhn commented and changed status Accepted Closed <span data-processor="relativetime" data-value="2024-02-09T14:18:06+00:00" > 02/09/24, 14:18 </span>

    closed as dupe of #92604

  5. 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 ..

  6. Gerrit Code Review pushed patch set 5 for main to change 83001 status Accepted Under Review <span data-processor="relativetime" data-value="2024-02-20T13:21:51+00:00" > 02/20/24, 13:21 </span>