Bug #92198

Localize method gets wrong PID from records generated during former free mode translations

Added by Jo Hasenau about 1 year ago. Updated 6 months ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Localization
Target version:
Start date:
2020-09-04
Due date:
% Done:

100%

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

Description

Marked for CMS 11 - but happens in any supported version as well.

If translations have been done in the so called "free mode" aka "copy mode", you can move around the translated elements after the actual localize actions.

If you move those elements to another page now, they still point to the record of the default language via the field configured as "translationSource".

Unfortunately this information will again be used for upcoming localize actions, since the destination PID will be either a real PID or a negative value pointing to a record after which to position the translation copy.

This will lead to problems in lines 7249 to 7255 of \TYPO3\CMS\Core\DataHandling\DataHandler

// If there is an element, find its localized record in specified localization language
if ($previousRow = $queryBuilder->execute()->fetch()) {
    $previousLocalizedRecord = BackendUtility::getRecordLocalization($table, $previousRow['uid'], $language);
    if (is_array($previousLocalizedRecord[0])) {
        $previousLocalizedRecordUid = $previousLocalizedRecord[0]['uid'];
    }
}

BackendUtility::getRecordLocalization will just use the UID of the record but not check the PID, so it might return a record from a different page based on the translationSource field.
Now this will lead to a wrong PID for each of the following records, since they will be copied "after" the first one with the wrong PID.

The result is a mixed up set of elements with different PID values which actually should be on the same page after the localize action.

Of course they could be moved around in free mode after that action, but for the actual localization only records from the same PID should be taken into account.

People noticed that behaviour when dealing with nested Gridelements structures, but even without any additional Gridelements methods activated the problem stayed the same.
Should be similar with any other localize action that involves translated elements which have been moved to another page before.


Related issues

Related to TYPO3 Core - Bug #92783: Record inserted on wrong pidClosedPhilipp Parzer2020-11-06

Actions
Related to TYPO3 Core - Bug #93078: 9.5/10.4: DataHandler::getPreviousLocalizedRecordUid() does not check pidResolved2020-12-15

Actions

Also available in: Atom PDF