Closed (cannot reproduce)
Project:
D7 Media
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Sep 2011 at 09:43 UTC
Updated:
12 Feb 2012 at 11:15 UTC
This is a problem in 7.x-1.0-beta5 and from a quick look at the code, appears to still be in 7.x-2.x-dev.
In media browser, going from 'Library' tab to another tab and back again results in the error in "Undefined index: file in media_browser_list()". This may occur under other circumstances as well when query in media_browser_list() (in media.browser.inc) returns empty. Offending code is (around line 175-9):
$result = $query->execute();
$files = file_load_multiple(array_keys($result['file']));
foreach ($files as $file) {
media_browser_build_media_item($file);
}
drupal_json_output(array('media' => array_values($files)));I suggest checking for empty result first:
$result = $query->execute();
$media = '';
if (!empty($result)) {
$files = file_load_multiple(array_keys($result['file']));
foreach ($files as $file) {
media_browser_build_media_item($file);
}
$media = array_values($files);
}
drupal_json_output(array('media' => $media));
Comments
Comment #1
dazweeja commentedActually this might be better (don't json encode if not necessary):
Comment #2
dddave commentedThis seems to be fixed by now. At least I am not able to reproduce it...