From e4037b06de34c9e81033ca07433e96e3fdb4b344 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Sat, 30 Mar 2013 18:39:16 -0400 Subject: Issue #985642 by kiamlaluno, Berdir, Damien Tournoud, Deciphered, B-Prod, galooph, David_Rothstein, drzraf, yched: Add back field_attach_load() to file_field_update() under certain circumstances in Drupal 7. --- modules/file/file.field.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'modules/file') diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 1189704fd..319cd5840 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -261,8 +261,16 @@ function file_field_update($entity_type, $entity, $field, $instance, $langcode, $current_fids[] = $item['fid']; } - // Compare the original field values with the ones that are being saved. - $original = $entity->original; + // Compare the original field values with the ones that are being saved. Use + // $entity->original to check this when possible, but if it isn't available, + // create a bare-bones entity and load its previous values instead. + if (isset($entity->original)) { + $original = $entity->original; + } + else { + $original = entity_create_stub_entity($entity_type, array($id, $vid, $bundle)); + field_attach_load($entity_type, array($id => $original), FIELD_LOAD_CURRENT, array('field_id' => $field['id'])); + } $original_fids = array(); if (!empty($original->{$field['field_name']}[$langcode])) { foreach ($original->{$field['field_name']}[$langcode] as $original_item) { -- cgit v1.2.3