Problem/Motivation

When cloning a translatable entity whose label field is not translatable, the suffix " - Cloned" gets appended once per translation instead of once total.

setClonedEntityLabel() iterates over all entity translations and calls $translation->set($label_key, $translation->label() . ' - Cloned') on each. For non-translatable fields, all translation objects share the same underlying field value in memory. Each iteration reads the already-modified value from the previous iteration, resulting in the suffix being appended N times (where N = number of translations).

Example: An entity with 4 translations (en, de, fr, it) and a non-translatable label My Entity produces My Entity - Cloned - Cloned - Cloned - Cloned instead of My Entity - Cloned. If the label field has a max_length constraint (e.g. 50 characters), this causes a database error on save.

Steps to reproduce

1. Create a translatable content entity type with a non-translatable label field
2. Create an entity with multiple translations
3. Clone it using entity_clone

Expected behavior:
The suffix " - Cloned" is appended exactly once regardless of the number of translations.

Actual behavior:
The suffix " - Cloned" is appended once per translation, e.g. My Entity - Cloned - Cloned - Cloned - Cloned.

CommentFileSizeAuthor
#3 3577269-3.patch1.37 KBdejan0

Comments

dejan0 created an issue. See original summary.

dejan0’s picture

Issue summary: View changes
dejan0’s picture

Status: Active » Needs review
StatusFileSize
new1.37 KB

Please find the patch attached