diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 1e90e87..6a64750 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -1245,10 +1245,7 @@ function field_attach_update(EntityInterface $entity) { $field = field_info_field_by_id($instance['field_id']); $field_id = $field['uuid']; $field_name = $field['field_name']; - // Leave the field untouched if $entity comes with no $field_name property, - // but empty the field if it comes as a NULL value or an empty array. - // Function property_exists() is slower, so we catch the more frequent - // cases where it's an empty array with the faster isset(). + // Ignore undefined fields. if ($entity->getPropertyDefinition($field_name)) { // Collect the storage backend if the field has not been written yet. if (!isset($skip_fields[$field_id])) { diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 71f10e5..dfbed25 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -308,15 +308,6 @@ function testFieldAttachSaveMissingData() { field_attach_load($entity_type, array($entity->id() => $entity)); $this->assertEqual($entity->{$this->field_name}->getValue(), $values, 'Field data saved'); - // Update: Field is missing. Data should survive. - field_cache_clear(); - $entity = clone($entity_init); - field_attach_update($entity); - - $entity = clone($entity_init); - field_attach_load($entity_type, array($entity->id() => $entity)); - $this->assertEqual($entity->{$this->field_name}->getValue(), $values, 'Update: missing field leaves existing values in place'); - // Update: Field is NULL. Data should be wiped. field_cache_clear(); $entity = clone($entity_init); @@ -378,7 +369,6 @@ function testFieldAttachSaveMissingDataDefaultValue() { // Insert: Field is missing. field_cache_clear(); $entity = clone($entity_init); - unset($entity->getBCEntity()->{$this->field_name}); field_attach_insert($entity); $entity = clone($entity_init);