Generated with the help of an LLM.
Problem/Motivation
Cloning a translatable entity copies only one translation. The other translations of the original are lost and have to be added again by hand.
Steps to reproduce
- Make a content type translatable and enable cloning for it.
- Create a node in English and translate it.
- Clone the English node and save the clone.
- The clone has only the English translation.
Proposed resolution
Add an opt-in "Copy all translations" setting per bundle. When it is on, the clone gets every translation of the original that the user can update, using the configured field processors.
Remaining tasks
Review the MR.
User interface changes
New checkbox on the bundle settings form, off by default.
API changes
None.
Data model changes
New boolean key copy_translations in the bundle settings config.
Comments
Comment #4
boychev commentedI opened !18 with the same change for 2.x, the default branch. There the code goes into
ContentEntityCloneHooks::entityPrepareForm(). The setting, the form and the README text are the same as in !17, which stays for 1.1.x.CopyTranslationsTestis the same apart from the 2.x conventions (theCloneQueryParameterenum for the query keys, and no@groupannotation).The kernel tests pass, locally on Drupal 11.4.13 and in the MR pipeline, and three of the four new tests fail without the hook change. The red jobs come from 2.x itself, not from this change:
phpunit: on Drupal 11.4.0 with twig 3.28,CloneNodeFunctionalTestgets a 500 on the node page, from a TypeError in core'sfield--node--title.html.twig.phpstan: a newer phpstan-drupal rule flags the existingentityOperation()hook, which lacks theCacheableMetadataparameter added in Drupal 11.3.phpunit (next minor): every test passes, but deprecations end each run with exit code 1.2.x has had no pipeline since July, so I could not compare it there.
Setting this to Needs review.
AI-assisted: Claude Code ported the change, ran the tests, read the CI logs and drafted this comment. I reviewed it.