diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-09-11 05:07:22 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-09-11 05:07:22 +0000 |
commit | f096a70e67a75e30dafd3e15448b579bfb1909c2 (patch) | |
tree | fa74a51731b788768f625ec6e3fa97e83491b448 /includes | |
parent | 8ce58d16744e44b1c166e820b88662197eaf6982 (diff) | |
download | brdo-f096a70e67a75e30dafd3e15448b579bfb1909c2.tar.gz brdo-f096a70e67a75e30dafd3e15448b579bfb1909c2.tar.bz2 |
#898036 by Berdir: Fixed Private images broken. (with tests)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/file.inc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/includes/file.inc b/includes/file.inc index 101c1a9e1..6550ae673 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -1808,9 +1808,19 @@ function file_download() { $uri = $scheme . '://' . $target; if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) { // Let other modules provide headers and controls access to the file. - $headers = module_invoke_all('file_download', $uri); - if (in_array(-1, $headers)) { - return drupal_access_denied(); + // module_invoke_all() uses array_merge_recursive() which merges header + // values into a new array. To avoid that and allow modules to override + // headers instead, use array_merge() to merge the returned arrays. + $headers = array(); + foreach (module_implements('file_download') as $module) { + $function = $module . '_file_download'; + $result = $function($uri); + if ($result == -1) { + return drupal_access_denied(); + } + if (isset($result) && is_array($result)) { + $headers = array_merge($headers, $result); + } } if (count($headers)) { file_transfer($uri, $headers); |