summaryrefslogtreecommitdiff
path: root/modules/file
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-03-30 18:39:16 -0400
committerDavid Rothstein <drothstein@gmail.com>2013-03-30 18:39:16 -0400
commite4037b06de34c9e81033ca07433e96e3fdb4b344 (patch)
tree1b77225bf191e94796142940e4be1b8f2bd3d3aa /modules/file
parentfb0ecf1802f66d5f394ce99447b113f1f5716c42 (diff)
downloadbrdo-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.inc12
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) {