Issue Bug Under Review

#111353Copying a translated record creates duplicate translations of records referenced with localizeReferencesAtParentLocalization

Peter Kraume 11/05/26, 16:27 updated 11/10/26, 06:19

Description

If a select or group field is configured with localizeReferencesAtParentLocalization = true, copying a record together with its translation creates a new translation of every record referenced in this field, although the referenced translation already exists. Every further copy adds another duplicate.

The backend shows only one translation of the referenced record, because translation lookups use LIMIT 1. In the select field of the translated record, however, the duplicates show up as additional, identical items.

Preconditions

  • A site with a default language (0) and a second language (1)
  • Two language-aware tables, e.g. tx_news_domain_model_news and tx_eventnews_domain_model_organizer
  • A select (or group) field without MM that references the second table, with localizeReferencesAtParentLocalization enabled:
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['organizer']['config'] = [
    'type' => 'select',
    'renderType' => 'selectSingle',
    'foreign_table' => 'tx_eventnews_domain_model_organizer',
    'localizeReferencesAtParentLocalization' => true,
];

Steps to reproduce

  1. Create an organizer (uid 1) in the default language and translate it into language 1 (uid 2).
  2. Create a news record in the default language with organizer = 1.
  3. Translate the news record into language 1. The translation correctly references organizer = 2.
  4. Copy the default language news record (e.g. copy & paste in the list module). Its translation is copied as well.

Expected result

The copied translation references the existing organizer translation (uid 2). No new organizer record is created.

Actual result

A new organizer record (uid 3, sys_language_uid = 1, l10n_parent = 1) is created, and the copied translation references it. Every further copy creates another one.

Cause

When the translation is copied, copyRecord_processManyToMany() is called with $language = 1. The field value already contains the translated uid 2. The method looks for a translation of uid 2 in language 1 (l10n_parent = 2), finds none and calls localize() for uid 2. localize() takes over the l10n_parent of uid 2 (= 1) and creates another translation of uid 1.

Reviews 1

History 02