Bug #92604

Translation of child elements connected to a page record currently broken

Added by Jo Hasenau about 1 month ago. Updated 2 days ago.

Status:
Under Review
Priority:
Must have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
Start date:
2020-10-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues

Is duplicate of TYPO3 Core - Bug #78743: Wrong translation behavior for pages/pages_language_overlayRejected2016-11-18

Actions
Is duplicate of TYPO3 Core - Bug #81346: Datahandler command localize doesn't copy relations when localizing a pageNew2017-05-26

Actions
#1

Updated by Jo Hasenau about 1 month ago

  • Description updated (diff)
#2

Updated by Jo Hasenau about 1 month ago

  • Description updated (diff)
#3

Updated by Jo Hasenau about 1 month ago

  • Is duplicate of Bug #78743: Wrong translation behavior for pages/pages_language_overlay added
#4

Updated by Jo Hasenau about 1 month ago

  • Description updated (diff)
#5

Updated by Jo Hasenau about 1 month ago

  • Is duplicate of Bug #81346: Datahandler command localize doesn't copy relations when localizing a page added
#6

Updated by Jo Hasenau about 1 month ago

  • Description updated (diff)
#7

Updated by Jo Hasenau about 1 month ago

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.

#8

Updated by Jo Hasenau about 1 month ago

  • Category changed from Localization to DataHandler aka TCEmain
#9

Updated by Jo Hasenau about 1 month ago

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.

#10

Updated by Jo Hasenau about 1 month ago

  • Subject changed from Translation of child elements together with the page record currently broken to Translation of child elements connected to a page record currently broken
#11

Updated by Jo Hasenau about 1 month ago

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') {}
#12

Updated by Benni Mack about 1 month ago

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?

#13

Updated by Jo Hasenau about 1 month ago

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.

#14

Updated by Gerrit Code Review about 1 month ago

  • Status changed from New to Under Review

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#15

Updated by Gerrit Code Review 10 days ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#16

Updated by Gerrit Code Review 4 days ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#17

Updated by Gerrit Code Review 3 days ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#18

Updated by Gerrit Code Review 3 days ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#19

Updated by Gerrit Code Review 3 days ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#20

Updated by Gerrit Code Review 3 days ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#21

Updated by Gerrit Code Review 3 days ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#22

Updated by Gerrit Code Review 3 days ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#23

Updated by Gerrit Code Review 3 days ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#24

Updated by Gerrit Code Review 3 days ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#25

Updated by Gerrit Code Review 2 days ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#26

Updated by Gerrit Code Review 2 days ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#27

Updated by Gerrit Code Review 2 days ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

#28

Updated by Gerrit Code Review 2 days ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66213

Also available in: Atom PDF