Issue Bug Closed

#110281Translation lookup misses translations with empty l10n_source

Stefan Bürk 07/23/26, 22:52 updated 08/11/26, 08:51

Description

LocalizationRepository::getRecordTranslation() and getRecordTranslations() look up an existing
translation by matching l10n_source whenever the table defines ctrl.translationSource, and fall
back to transOrigPointerField only when the table has no translation source field at all:

// Prefer translationSourceField (l10n_source) over transOrigPointerField (l10n_parent)
$parentPointerField = $languageCapability->hasTranslationSourceField()
? $languageCapability->getTranslationSourceField()->getName()
: $languageCapability->getTranslationOriginPointerField()->getName();

A translation carrying a correct l10n_parent but an empty l10n_source is therefore not found,
although it is a perfectly valid translation.

Such records are created by TYPO3 itself: a DataHandler datamap which creates a translation by
setting only the language field and l18n_parent does not populate l10n_source. This is the usual way
extensions, importers and migrations create translations, and it produces no error.

Reproduction

The test fixtures of the affected class already contain such records – the pages rows in
typo3/sysext/backend/Tests/Functional/Domain/Repository/Localization/Fixtures/TranslationTestData.csv
have l10n_parent set and no l10n_source column at all. Adding this test to LocalizationRepositoryTest
fails on current main:

#[Test]
public function getRecordTranslationReturnsTranslationWithEmptyTranslationSource(): void {
$this->importCSVDataSet(__DIR__ . '/Fixtures/TranslationTestData.csv');
$result = $this->subject->getRecordTranslation('pages', 1001, 1);
self::assertNotNull($result);
self::assertSame(1002, $result->getUid());
}
1) LocalizationRepositoryTest::getRecordTranslationReturnsTranslationWithEmptyTranslationSource
Failed asserting that null is not null.

Impact

DataHandler::localize() uses this lookup as its “there already are localizations” guard. Because the
existing translation is invisible, the guard does not trigger and a second translation of the same
record in the same language
is created. Repeating the operation multiplies the records.

Verified on TYPO3 13.4 with the predecessor API BackendUtility::getRecordLocalization(), which
carries the identical translationSource / transOrigPointerField expression: a page with a valid
l10n_parent but l10n_source = 0 received a duplicate page translation, and inline children were
attached to the duplicate, making them invisible in the backend.

Suggested fix

Keep preferring l10n_source – it is the more precise field for translation chains – but do not let an
empty value hide the record. Either

  • fall back to a transOrigPointerField lookup when the translationSource based query returns nothing, or
  • widen the condition to “l10n_source = uid OR (l10n_source = 0 AND l10n_parent = uid)”.

Both keep the current behaviour for well-formed data and only add the records which are currently
lost. The same applies to BackendUtility::getRecordLocalization() in 13.4 and 12.4.

Reviews 9