diff --git a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php index 37c7a24..cbf1a53 100644 --- a/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php +++ b/core/modules/entity/lib/Drupal/entity/DatabaseStorageController.php @@ -504,7 +504,7 @@ class DatabaseStorageController implements EntityStorageControllerInterface { */ protected function invokeHook($hook, EntityInterface $entity, EntityInterface $original = NULL) { if (!empty($this->entityInfo['fieldable']) && function_exists($function = 'field_attach_' . $hook)) { - $function($this->entityType, $entity); + $function($this->entityType, $entity, $original); } // Invoke the hook. module_invoke_all($this->entityType . '_' . $hook, $entity, $original); diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 455ecc2..7b5edb9 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -480,7 +480,7 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, * * @param $entity_type * The type of $entity. - * @param $entity + * @param Drupal\entity\EntityInterface $entity * The entity for the operation. * @param $field * The field structure for the operation. @@ -490,11 +490,13 @@ function hook_field_insert($entity_type, $entity, $field, $instance, $langcode, * The language associated with $items. * @param $items * $entity->{$field['field_name']}[$langcode], or an empty array if unset. + * @param Drupal\entity\EntityInterface $original + * The original entity, or NULL if the caller did not provide it. * * @see hook_field_insert() * @see hook_field_delete() */ -function hook_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) { +function hook_field_update($entity_type, Drupal\entity\EntityInterface $entity, $field, $instance, $langcode, &$items, Drupal\entity\EntityInterface $original = NULL) { if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node') { $first_call = &drupal_static(__FUNCTION__, array()); diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index e4b28a9..122272d 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -5,6 +5,7 @@ * Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'. */ +use Drupal\entity\EntityInterface; use Drupal\field\FieldValidationException; /** @@ -127,6 +128,7 @@ const FIELD_STORAGE_INSERT = 'insert'; * @param $a * - The $form in the 'form' operation. * - The value of $view_mode in the 'view' operation. + * - The original entity in the 'update' operation. May be NULL. * - Otherwise NULL. * @param $b * - The $form_state in the 'submit' operation. @@ -929,11 +931,13 @@ function field_attach_insert($entity_type, $entity) { * * @param $entity_type * The type of $entity; e.g. 'node' or 'user'. - * @param $entity + * @param EntityInterface $entity * The entity with fields to save. + * @param EntityInterface $original + * The original entity. May be NULL. */ -function field_attach_update($entity_type, $entity) { - _field_invoke('update', $entity_type, $entity); +function field_attach_update($entity_type, EntityInterface $entity, EntityInterface $original = NULL) { + _field_invoke('update', $entity_type, $entity, $original); list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 768ee7d..d7c2dc7 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -1,5 +1,7 @@ original; $original_fids = array(); if (!empty($original->{$field['field_name']}[$langcode])) { foreach ($original->{$field['field_name']}[$langcode] as $original_item) { diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 2a32c15..de30e30 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -1,5 +1,7 @@