Issue Bug New Good first issue

#105343Invalid selection of content elements given on translate or copy function when a content element has no relation

Joey Bouten 10/18/24, 08:43 updated 11/09/26, 11:02

Description

https://github.com/TYPO3/typo3/blob/main/typo3/sysext/backend/Classes/Domain/Repository/Localization/LocalizationRepository.php

Function `->getRecordsToCopyDatabaseResult()` should return all elements which are available for selection for translation or copy. However imagine you have default language (EN) and translation German (2). Where the there are 10 content elements in default and only 6 of them translated in German.

When 1 content element is set in german which does not have any relation (so l10n_source = 0) the while loop exits.
@
while ($origUid = $originalUidsStatement->fetchOne()) {
$originalUids[] = (int)$origUid;
}@

If this happens to be the 2nd element in the array all others are skipped and not taking into the next query to exclude them from listing. Resulting in a list of items which are available for translation or copy while there already is an content element with a translation.

Reviews 1

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] Invalid selection of content elements given on translate or copy function when a content element has no relation Resolves: #105343 Releases: main

History 45

  1. Joey Bouten commented <span data-processor="relativetime" data-value="2024-10-18T08:46:02+00:00" > 10/18/24, 08:46 </span>

    Possible fix: Instead of while loop


    $results = $originalUidsStatement->fetchAllAssociative();
    foreach ($results as $row) {
    if((int)$row['l10n_source'] === 0) {
    continue;
    }
    $originalUids[] = (int)$row['l10n_source'];
    }