Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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)));
}
}
Comment | File | Size | Author |
---|---|---|---|
#2 | 1512718-media-browser-form-submit-multiple-files.patch | 541 bytes | Dave Reid |
#1 | media-multiple-file-upload-error-1512718.patch | 433 bytes | exratione |
Comments
Comment #1
exratione CreditAttribution: 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 CreditAttribution: 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) CreditAttribution: commentedTypo