diff options
author | David Rothstein <drothstein@gmail.com> | 2013-12-29 16:53:44 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-12-29 16:53:44 -0500 |
commit | b5f311a892709002d460ad32a432ca3a0a9c9f23 (patch) | |
tree | af6e3de908a83a1516b179902def1a9fa7e6e695 | |
parent | 257fac8454924bb2f09aaee6a112f9f86f7520f1 (diff) | |
download | brdo-b5f311a892709002d460ad32a432ca3a0a9c9f23.tar.gz brdo-b5f311a892709002d460ad32a432ca3a0a9c9f23.tar.bz2 |
Issue #1443158 by agentrickard, Dave Reid, marcingy: File_field_presave assumes that a file object has been loaded.
-rw-r--r-- | CHANGELOG.txt | 4 | ||||
-rw-r--r-- | modules/file/file.field.inc | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 082efb254..947a8e2b1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,10 @@ Drupal 7.25, xxxx-xx-xx (development version) ----------------------- +- Made the File and Image modules more robust when saving entities that have + deleted files attached. The code in file_field_presave() will now remove the + record of the deleted file from the entity before saving (minor data + structure change). - Standardized menu callback functions throughout Drupal core to return MENU_NOT_FOUND and MENU_ACCESS_DENIED rather than printing their own "page not found" or "access denied" pages (minor API change in the return value of diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index c841f60ee..d540c0aa5 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -215,8 +215,16 @@ function file_field_presave($entity_type, $entity, $field, $instance, $langcode, // Make sure that each file which will be saved with this object has a // permanent status, so that it will not be removed when temporary files are // cleaned up. - foreach ($items as $item) { + foreach ($items as $delta => $item) { + if (empty($item['fid'])) { + unset($items[$delta]); + continue; + } $file = file_load($item['fid']); + if (empty($file)) { + unset($items[$delta]); + continue; + } if (!$file->status) { $file->status = FILE_STATUS_PERMANENT; file_save($file); |