Problem/Motivation

1. Create a entity with one default and one additional translation.
2. Clone the entity additional translation.
3. Enforce the cloned entity to be new.
4. The change is propagated to the original entity and if you try to save it now -> entity storage exception about trying to save a new entity with an id that already exist.

Having cases where you are using entities with multiple translations and in some cases the user might trigger createDuplicate on a entity translation and later save the original entity will lead to data loss => this per definition is major.

Proposed resolution

ContentEntityBase::__clone should consider the enforceIsNew flag as well when overwriting the properties.

Remaining tasks

Commit

User interface changes

none

API changes

none

Data model changes

none

Comments

hchonov created an issue. See original summary.

hchonov’s picture

StatusFileSize
new1.29 KB

Status: Needs review » Needs work
hchonov’s picture

Status: Needs work » Needs review
penyaskito’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Great catch :)

Reviewed the code and the tests, fix looks good and the new clone test is right after other clone tests.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!

  • catch committed d2ab9b8 on 8.2.x
    Issue #2772979 by hchonov: Enforcing a cloned entity translation to be...

  • catch committed 33c271d on 8.1.x
    Issue #2772979 by hchonov: Enforcing a cloned entity translation to be...

  • catch committed d2ab9b8 on 8.3.x
    Issue #2772979 by hchonov: Enforcing a cloned entity translation to be...

  • catch committed d2ab9b8 on 8.3.x
    Issue #2772979 by hchonov: Enforcing a cloned entity translation to be...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.