Download & Extend

Notice: Undefined index: file in media_edit_submit()

Project:Media
Version:7.x-1.x-dev
Component:Media field
Category:bug report
Priority:major
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I added field "description" to image file type. Everything went ok but when i tried to fill this field under admin/content/media and saved it i see this message:
Notice: Undefined index: file in media_edit_submit() (line 366 of (...)\drupal\sites\all\modules\media\includes\media.pages.inc).
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7562 of (...)\drupal\includes\common.inc).

Comments

#1

Priority:normal» major

#2

Version:7.x-1.2» 7.x-1.x-dev
Category:support request» bug report
Status:active» needs review

I have attached a patch that fixes this issue for me.

I believe this is caused $form_state is not passed by reference to the function media_edit. So right now:

function media_edit($form, &$form_state, $file) {
  $form_state['file'] = $file;

Doesn't affect $form_state outside of the form. Then in

function media_edit_submit($form, &$form_state) {
  $file = $form_state['file'];

The file is not actually in $form_state.

AttachmentSizeStatusTest resultOperations
media-pass_form_state_byref_media_edit-1723820-2.patch489 bytesIdleFAILED: [[SimpleTest]]: [MySQL] 11 pass(es), 0 fail(s), and 12 exception(s).View details

#3

Status:needs review» needs work

The last submitted patch, media-pass_form_state_byref_media_edit-1723820-2.patch, failed testing.

#4

confirmed that this is an issue in 7.x-1.-dev.

Also, I tried the patch in #2 and I believe it is the correct solution. Obviously we need to figure out why its failing though...

#5

Ok, If you click view details for the patch you will see that all the exceptions(no errors found) are similar to this:

Use of undefined constant FILE_TYPE_NONE - assumed 'FILE_TYPE_NONE' Notice media.types.inc 245 media_type_invalid_files_count()

With different line numbers.

Is this an existing problem in Media? I don't see how my patch could have caused this. But this is the first time I have looked at Media's code.

#6

Status:needs work» fixed

Thanks, I committed #2 to Git. http://drupalcode.org/project/media.git/commit/6d25709

We can fix the test failures separately.

#7

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.