diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-05 08:56:34 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-05 08:56:34 +0000 |
commit | efbf061c8142c201967389eac42e8284dfa9aff9 (patch) | |
tree | 3268ef89294cbb96d0875d665012c4ff16d8c68a /modules/file | |
parent | 4f28649fc3841e82e2b5347deff8d1157e2a657d (diff) | |
download | brdo-efbf061c8142c201967389eac42e8284dfa9aff9.tar.gz brdo-efbf061c8142c201967389eac42e8284dfa9aff9.tar.bz2 |
#852522 by catch: Optimize file_field_load() to load filefields on all entities at once.
Diffstat (limited to 'modules/file')
-rw-r--r-- | modules/file/file.field.inc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc index 8184ae8bd..69b872de7 100644 --- a/modules/file/file.field.inc +++ b/modules/file/file.field.inc @@ -208,16 +208,19 @@ function _file_generic_settings_file_directory_validate($element, &$form_state) * Implements hook_field_load(). */ function file_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) { + + $fids = array(); foreach ($entities as $id => $entity) { // Load the files from the files table. - $fids = array(); foreach ($items[$id] as $delta => $item) { if (!empty($item['fid'])) { $fids[] = $item['fid']; } } - $files = file_load_multiple($fids); + } + $files = file_load_multiple($fids); + foreach ($entities as $id => $entity) { foreach ($items[$id] as $delta => $item) { // If the file does not exist, mark the entire item as empty. if (empty($item['fid']) || !isset($files[$item['fid']])) { |