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).

#2 media-pass_form_state_byref_media_edit-1723820-2.patch489 bytestedbow
FAILED: [[SimpleTest]]: [MySQL] 11 pass(es), 0 fail(s), and 12 exception(s). View
Members fund testing for the Drupal project. Drupal Association Learn more


rychu90’s picture

Priority: Normal » Major
tedbow’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Category: support » bug
Status: Active » Needs review
489 bytes
FAILED: [[SimpleTest]]: [MySQL] 11 pass(es), 0 fail(s), and 12 exception(s). View

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.

Status: Needs review » Needs work

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

bleen’s picture

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...

tedbow’s picture

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.

Dave Reid’s picture

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.

Status: Fixed » Closed (fixed)

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