core/lib/Drupal/Core/Entity/ContentEntityBase.php | 6 ++++-- core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index d51b5a7..9c5eb9f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -1005,7 +1005,9 @@ public function &__get($name) { /** * Implements the magic method for setting object properties. * - * Uses default language always. + * Always: + * - uses default language + * - notifies parent */ public function __set($name, $value) { // Inline getFieldDefinition() to speed things up. @@ -1020,7 +1022,7 @@ public function __set($name, $value) { } // If a FieldItemList object already exists, set its value. if (isset($this->fields[$name][$this->activeLangcode])) { - $this->fields[$name][$this->activeLangcode]->setValue($value); + $this->fields[$name][$this->activeLangcode]->setValue($value, TRUE); } // If not, create one. else { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 9d6b8d6..ad521ec 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -102,14 +102,17 @@ protected function doCreate(array $values) { * is provided all fields will be initialized. */ protected function initFieldValues(ContentEntityInterface $entity, array $values = [], array $field_names = []) { + // Do not notify when setting values, because these are initial values. + $notify = FALSE; + // Populate field values. foreach ($entity as $name => $field) { if (!$field_names || isset($field_names[$name])) { if (isset($values[$name])) { - $entity->$name = $values[$name]; + $entity->$name->setValue($values[$name], $notify); } elseif (!array_key_exists($name, $values)) { - $entity->get($name)->applyDefaultValue(); + $entity->get($name)->applyDefaultValue($notify); } } unset($values[$name]);