Project

General

Profile

Actions

Bug #92604

open

Translation of child elements connected to a page record currently broken

Added by Jo Hasenau over 3 years ago. Updated about 2 months 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 4 (0 open4 closed)

Related to TYPO3 Core - Task #79610: Cache results in doesRecordExist_pageLookUpClosedThomas Hohn2017-02-03

Actions
Related to TYPO3 Core - Task #103172: Avoid runtime caching pages in DataHandlerResolved2024-02-21

Actions
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 pageClosed2017-05-26

Actions
Actions #1

Updated by Jo Hasenau over 3 years ago

  • Description updated (diff)
Actions #2

Updated by Jo Hasenau over 3 years ago

  • Description updated (diff)
Actions #3

Updated by Jo Hasenau over 3 years ago

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

Updated by Jo Hasenau over 3 years ago

  • Description updated (diff)
Actions #5

Updated by Jo Hasenau over 3 years ago

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

Updated by Jo Hasenau over 3 years ago

  • Description updated (diff)
Actions #7

Updated by Jo Hasenau over 3 years 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.

Actions #8

Updated by Jo Hasenau over 3 years ago

  • Category changed from Localization to DataHandler aka TCEmain
Actions #9

Updated by Jo Hasenau over 3 years 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.

Actions #10

Updated by Jo Hasenau over 3 years 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
Actions #11

Updated by Jo Hasenau over 3 years 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') {}
Actions #12

Updated by Benni Mack over 3 years 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?

Actions #13

Updated by Jo Hasenau over 3 years 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.

Actions #14

Updated by Gerrit Code Review over 3 years 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

Actions #15

Updated by Gerrit Code Review over 3 years 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

Actions #16

Updated by Gerrit Code Review over 3 years 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

Actions #17

Updated by Gerrit Code Review over 3 years 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

Actions #18

Updated by Gerrit Code Review over 3 years 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

Actions #19

Updated by Gerrit Code Review over 3 years 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

Actions #20

Updated by Gerrit Code Review over 3 years 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

Actions #21

Updated by Gerrit Code Review over 3 years 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

Actions #22

Updated by Gerrit Code Review over 3 years 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

Actions #23

Updated by Gerrit Code Review over 3 years 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

Actions #24

Updated by Gerrit Code Review over 3 years 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

Actions #25

Updated by Gerrit Code Review over 3 years 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

Actions #26

Updated by Gerrit Code Review over 3 years 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

Actions #27

Updated by Gerrit Code Review over 3 years 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

Actions #28

Updated by Gerrit Code Review over 3 years 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

Actions #29

Updated by Benni Mack over 3 years ago

  • Status changed from Under Review to Accepted
Actions #30

Updated by Christian Kuhn 2 months ago · Edited

  • Status changed from Accepted to Closed

closed as dupe of #92604

Actions #31

Updated by Felix Nagel 2 months ago

@Christian Kuhn Closed as duplicate of itself?

Actions #32

Updated by Riccardo De Contardi 2 months ago

  • Status changed from Closed to Accepted
Actions #33

Updated by Christian Kuhn 2 months ago

Oops ... I of course meant I closed #81346 as dupe of this one ..

Actions #34

Updated by Gerrit Code Review about 2 months ago

  • Status changed from Accepted to Under Review

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

Actions #35

Updated by Christian Kuhn about 2 months ago

  • Related to Task #79610: Cache results in doesRecordExist_pageLookUp added
Actions #36

Updated by Christian Kuhn about 2 months ago

  • Related to Task #103172: Avoid runtime caching pages in DataHandler added
Actions

Also available in: Atom PDF