Skip to content

Commit

Permalink
Issue #985642 by kiamlaluno, Berdir, Damien Tournoud, Deciphered, B-P…
Browse files Browse the repository at this point in the history
…rod, galooph, David_Rothstein, drzraf, yched: Add back field_attach_load() to file_field_update() under certain circumstances in Drupal 7.
  • Loading branch information
DavidRothstein committed Mar 30, 2013
1 parent fb0ecf1 commit e4037b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/file/file.field.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e4037b0

Please sign in to comment.