diff options
author | David Rothstein <drothstein@gmail.com> | 2013-03-30 18:39:16 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-03-30 18:39:16 -0400 |
commit | e4037b06de34c9e81033ca07433e96e3fdb4b344 (patch) | |
tree | 1b77225bf191e94796142940e4be1b8f2bd3d3aa /modules/file | |
parent | fb0ecf1802f66d5f394ce99447b113f1f5716c42 (diff) | |
download | brdo-e4037b06de34c9e81033ca07433e96e3fdb4b344.tar.gz brdo-e4037b06de34c9e81033ca07433e96e3fdb4b344.tar.bz2 |
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.
Diffstat (limited to 'modules/file')
-rw-r--r-- | modules/file/file.field.inc | 12 |
1 files changed, 10 insertions, 2 deletions
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) { |