diff -u b/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php --- b/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -617,25 +617,13 @@ break; } - if (!isset($this->changedFields[$name][$this->activeLangcode])) { - // A Translation is marked dirty if the translated value of a translatable - // field changed or is new. - // @todo This detection of modifications needs to be replaced by FieldItemList::equals() as soon it's available - // - $value = $this->{$name}->getValue(); - foreach ($this->get($name) as $key => $field) { - $mainPropertyName = $field->mainPropertyName(); - if (!$mainPropertyName) { - // @todo could that happen, that there's no main property? - $this->changedFields[$name][$this->activeLangcode] = TRUE; - break; - } - elseif (isset($value[$key][$mainPropertyName]) && (!isset($this->values[$name][$this->activeLangcode][$key][$mainPropertyName]) - || $value[$key][$mainPropertyName] != $this->values[$name][$this->activeLangcode][$key][$mainPropertyName]) - ) { - $this->changedFields[$name][$this->activeLangcode] = TRUE; - break; - } + if (!isset($this->changedFields[$name][$this->activeLangcode]) && isset($this->values[$name][$this->activeLangcode])) { + $items = $this->get($name)->filterEmptyItems(); + $value = $this->values[$name][$this->activeLangcode]; + $originalItems = \Drupal::service('plugin.manager.field.field_type')->createFieldItemList($this, $name, $value)->filterEmptyItems(); + // If the field items are not equal, we mark them changed. + if (!$items->equals($originalItems)) { + $this->changedFields[$name][$this->activeLangcode] = TRUE; } } } @@ -1106,32 +1094,2 @@ - /** - * {@inheritdoc} - */ - public function getChangedTime() { - if ($this->hasField('changed')) { - return $this->get('changed')->value; - } - else { - throw new EntityChangedException( - sprintf('The entity type %s has no changed field.', - $this->getEntityTypeId() - ) - ); - } - } - - /** - * {@inheritdoc} - */ - public function getChangedTimeAcrossTranslations() { - $changed = $this->getUntranslated()->getChangedTime(); - foreach ($this->getTranslationLanguages(FALSE) as $language) { - $translation_changed = $this->getTranslation($language->getId())->getChangedTime(); - if ($translation_changed > $changed) { - $changed = $translation_changed; - } - } - return $changed; - } - } reverted: --- b/core/lib/Drupal/Core/Entity/Exception/EntityChangedException.php +++ /dev/null @@ -1,14 +0,0 @@ -get('changed')->value; + } + + /** + * Returns the timestamp of the last entity change across all translations. + * + * @return int + * The timestamp of the last entity save operation across all + * translations. + */ + public function getChangedTimeAcrossTranslations() { + $changed = $this->getUntranslated()->getChangedTime(); + foreach ($this->getTranslationLanguages(FALSE) as $language) { + $translation_changed = $this->getTranslation($language->getId())->getChangedTime(); + if ($translation_changed > $changed) { + $changed = $translation_changed; + } + } + return $changed; + } + +}