I am running a German localized version of drupal. When I tried to import files from the file system (additionally I did not find a link to the import, but entered the url /admin/content/media/import manually), in the last step/page of the import process, I got the following error message:
Notice: Undefined index: directory in media_import_validate() (line 484 of /var/www/drupal7/sites/all/modules/media/media.admin.inc).
Notice: Undefined index: pattern in media_import_validate() (line 485 of /var/www/drupal7/sites/all/modules/media/media.admin.inc).
The provided directory does not exist.
Additionally the import keeps locked in this stage, i.e. does not really import the files but "calls" the page again.
I got it working using the following fix: In media.admin.inc there are two functions, media_import_validate and media_import_submit which are responsible for handling these stages of the import. The first lines there are:
if ($form_state['values']['op'] == 'Confirm') {
and
if ($form_state['values']['op'] != 'Confirm') {
However, due to the localisation, I guess $form_state['values']['op'] contains not 'Confirm', but the translated version, t('Confirm'), e.g. "Bestätigen" in German. So I changed these lines to
if ($form_state['values']['op'] == t('Confirm')) {
and
if ($form_state['values']['op'] != t('Confirm')) {
and it works just fine.
Can anyone please check and confirm?
Comments
Comment #1
JacobSingh commentedThanks! Committed it.
tbh, the whole way that form is handled is kinda backwards, but this little fix at least eases the pain. Great to have non-english languages being used w/ Media. Please keep filing bugs. our l10n testing has been near zero thus far.
Comment #3
alldirt commentedThis bug still persists in function "media_import_submit".
The proposed fix works for me.
Comment #4
tommychris#3 writes the truth.
Comment #5
dave reidThanks, fixed the untranslated string in media_import_submit() as well.
http://drupalcode.org/project/media.git/commit/bfe2054 (7.x-2.x)
http://drupalcode.org/project/media.git/commit/1915a9f (7.x-1.x)