core/lib/Drupal/Core/Entity/ContentEntityBase.php | 11 +++++++++-- core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php | 3 ++- core/lib/Drupal/Core/Entity/FieldableEntityInterface.php | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 47659d4..9c5eb9f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -262,7 +262,6 @@ protected function getLanguages() { */ public function postCreate(EntityStorageInterface $storage) { $this->newRevision = TRUE; - $this->changedFields = []; } /** @@ -398,7 +397,7 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); - $this->changedFields = []; + $this->resetChangedFieldList(); // Update the status of all saved translations. $removed = []; @@ -588,6 +587,14 @@ public function getChangedFields() { /** * {@inheritdoc} */ + public function resetChangedFieldList() { + $this->changedFields = []; + return $this; + } + + /** + * {@inheritdoc} + */ public function getTranslatableFields($include_computed = TRUE) { $fields = []; foreach ($this->getFieldDefinitions() as $name => $definition) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 6449470..fba244a 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -86,6 +86,7 @@ protected function doCreate(array $values) { } $entity = new $this->entityClass([], $this->entityTypeId, $bundle); $this->initFieldValues($entity, $values); + $entity->resetChangedFieldList(); return $entity; } @@ -135,7 +136,7 @@ public function createTranslation(ContentEntityInterface $entity, $langcode, arr $values[$this->getEntityType()->getKey('default_langcode')] = FALSE; $this->initFieldValues($translation, $values, $field_names); $this->invokeHook('translation_create', $translation); - $translation->postCreate($this); + $translation->resetChangedFieldList(); return $translation; } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php index 0ee2c7a..90f7cff 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php @@ -244,4 +244,11 @@ public function setValidationRequired($required); */ public function getChangedFields(); + /** + * Resets the list an array of changed field names. + * + * @return $this + */ + public function resetChangedFieldList(); + }