When adding multiple files (via plupload in this case), errors occur in media_browser_form_submit():
Notice: Undefined variable: file in media_browser_form_submit() (line 579 of /sites/all/modules/contrib/media/media.module).
Notice: Trying to get property of non-object in media_browser_form_submit() (line 579 of /sites/all/modules/contrib/media/media.module).
Exception: Error selecting media, fid param is not an fid or an array of fids in media_browser() (line 38 of /sites/all/modules/contrib/media/includes/media.browser.inc).
This is because this function:
function media_browser_form_submit($form, &$form_state) {
if (!empty($form_state['file'])) {
$file = $form_state['file'];
$form_state['redirect'] = array('media/browser', array('query' => array('render' => 'media-popup', 'fid' => $file->fid)));
}
if (!empty($form_state['files'])) {
$files = $form_state['files'];
$form_state['redirect'] = array('media/browser', array('query' => array('render' => 'media-popup', 'fid' => $file->fid)));
}
}
Should have an additional line:
function media_browser_form_submit($form, &$form_state) {
if (!empty($form_state['file'])) {
$file = $form_state['file'];
$form_state['redirect'] = array('media/browser', array('query' => array('render' => 'media-popup', 'fid' => $file->fid)));
}
if (!empty($form_state['files'])) {
$files = $form_state['files'];
$file = current($files);
$form_state['redirect'] = array('media/browser', array('query' => array('render' => 'media-popup', 'fid' => $file->fid)));
}
}
Comments
Comment #1
exratione commentedPatch attached.
Comment #2
dave reidHrm, I don't think this is correct since it would break the multi-upload functionality if it were supported. Please try the following patch.
Comment #3
exratione commentedPatch in #2 tried, works.
Comment #4
dave reidCommitted #2 to 7.x-2.x: http://drupalcode.org/project/media.git/commit/d0149ad
Comment #5.0
(not verified) commentedTypo