Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295019

Cloning an entity with initialized translations leaves $values pointing to the old entity object

$
0
0

Problem/Motivation

This issue is similar to #2772979: Enforcing a cloned entity translation to be new propagates to the original entity and #2828073: Cloning an entity with initialized translations leaves $entityKeys and $translatableEntityKeys pointing to the old entity object and the problem has been initially mentioned in #2828073: Cloning an entity with initialized translations leaves $entityKeys and $translatableEntityKeys pointing to the old entity object, but in order to keep each problem separately there is an isolated issue for the $values entity property.

What happens is that if an entity with at least one translation initialized is cloned then the $values property will be shared between the clone and the original entity and under circumstances the values of both entity will get mixed up. An example use is:

  1. Create an entity with at least one translation.
  2. Clone the entity or its translation.
  3. Alter a field value on the cloned entity object.
  4. Serialize the entity and the clone.
  5. Read out the value of the field that has been changed from the original entity.
  6. The returned value now is not the one from the original entity, but the altered one from the cloned entity object.

Proposed resolution

Break the reference of the property $values in CEB::__clone().

Remaining tasks

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 295019

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>