After upgrading to latest media, media_gallery & file_entity 2.x on drupal 7.16, trying to view an existing gallery gives:

Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 of ...\sites\all\modules\media_gallery\media_gallery.module).
Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 of ...\sites\all\modules\media_gallery\media_gallery.module).
Warning: array_filter() [function.array-filter]: The first argument should be an array in media_gallery_view() (line 319 of ...\sites\all\modules\media_gallery\media_gallery.module).
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7562 of ...\includes\common.inc).

Please any ideas? Thanks

Comments

Title:errors after ugrade to media_gallery 2.xerrors after upgrade to media_gallery 2.x - Undefined property: stdClass::$media_gallery_file in media_gallery_node_load()

Same issue when I create a new gallery too. Image added but can't see anything when viewing the gallery. Get similar error above.

I am using dev version of 2012-12-26. Should I be using an earlier version?

Priority:Normal» Major

I am getting the same exact errors with Drupal 7.18 and these modules which are all current:

ACL 7.x-1.0
Calendar 7.x-3.4
CAPTCHA 7.x-1.0-beta2
CAPTCHA Pack 7.x-1.0-alpha1
Chaos tool suite (ctools) 7.x-1.2
CKEditor - WYSIWYG HTML editor 7.x-1.12
Colorbox 7.x-1.4
Content Access 7.x-1.2-beta1
Date 7.x-2.6
Entity API 7.x-1.0
File entity (fieldable files) 7.x-2.0-unstable7
Gallery formatter 7.x-1.3
Google Analytics 7.x-1.3
Libraries API 7.x-1.0
Media 7.x-2.0-unstable7
Media Browser Plus 7.x-2.x-dev (2013-Jan-03)
Media Gallery 7.x-2.x-dev (2012-Dec-25)
Media Gallery Extra 7.x-1.x-dev (2012-Jul-30)
Module Filter 7.x-1.7
Multiple forms 7.x-1.0
Node access node reference 7.x-1.22
Node access user reference 7.x-3.9
Pathauto 7.x-1.2
Plupload integration 7.x-1.0
References 7.x-2.0
Rules 7.x-2.2
Token 7.x-1.4
URL field 7.x-1.0-rc1
Views 7.x-3.5
Views Media Browser 7.x-1.0
Webform 7.x-3.18
AdaptiveTheme 7.x-2.3
AT Commerce 7.x-2.0-rc3

Help?!?

same here

Same here. Upgraded and now not working.

same problem here

Same problem here

I may be wrong but I think the bug could be there:
In media_gallery.fields.inc,

  // Prepare the referenced file entities for viewing.
  $files = array();
  foreach ($items as $delta => $item) {
    $file = (object)$item;
    // Pass along formatter reference field values from the gallery to the file.
    foreach ($formatter_reference_fields as $field_name) {
      if (!isset($file->{$field_name}) && isset($entity->{$field_name})) {
        $file->{$field_name} = $entity->{$field_name};
      }
    }
    // Set a default value for the file's media_title field.
    // @todo Eventually, fix this to take into account the possibility of a
    //   multilingual media title field.
    if (isset($file->media_title) && !isset($file->media_title[LANGUAGE_NONE][0]['value'])) {
      $file->media_title[LANGUAGE_NONE][0]['value'] = _media_gallery_get_media_title($file);
    }
    $files[$file->fid] = $file;
  }
  field_attach_prepare_view('file', $files, $file_view_mode);
  entity_prepare_view('file', $files);

Here, $files is filled with items, but it should be filled with file objects:
$files[$file->fid] = $file->file;

Ignore my previous comment... there was an error in the update process from 7.x-1.x to 7.x-2.x and the gallery media field was not updated to file field.

Were you able to fix the field?

I fixed it manually in the database.

how did you do it?

I don't remember all the steps, but basically, I changed the name and the type in field_config and field_config_instance. After that I renamed field_data_media_gallery_media table in field_data_media_gallery_file (same action for revision tables), then I created a temporary file field (with the content type UI) to see how it's structured in database... and I renamed the fields (the last three) in the table field_data_media_gallery_file as in the file field (and again, the same in the revision table). Then I cleared the cache.

Status:Active» Needs review
StatusFileSize
new2.55 KB

We had the same issue when upgrading an older version to 2.x

I've attached a patch which adds a hook_update_N() function to create the new media_gallery_file field and convert all of the existing data.

I've just used the patch in #13 by markpavlitski and that fixed my problems!

#13 didn't work for me. What did you do after you installed the patch?

I Installed it, then ran the awaiting database updates with the site in maintenance mode. This fixed it for me!

I installed it, but I don't see any awaiting database updates. Does this only work the initial time you upgrade from 1 to 2?

The patch itself should add updates, that is the sole point of it. Can you double check the patch applied correctly? If I remember correctly I may have had to manually help applying the patch, however the actual content is perfect.

@markpavlitski Could you double check that patch?

FWIW, I manually installed the patch directly to the module on my server.

I rolled back my database to before I initially went from Media/MG to ver 2 and did and ran the update again with your patch in place. I did see the updates this time and they appeared to run fine but I'm still getting the same errors that the OP reported.

Actually the did initial get an errors about Media not being able to find the View module (which is installed) but after updating Media from Alpha 1 to todays dev release it did the upgrade fine. Would the Media modules updates not being run at the same time maybe cause the patch not to work right.

Awesome, applied #13 and got rid of the errors. Thanks a bunch.

Can this get integrated in the code?

Status:Needs review» Reviewed & tested by the community

Works!

Thanks, patch #13 fixed it!

Issue summary:View changes
Status:Reviewed & tested by the community» Fixed

Update functions are always welcome! Thank you!

http://drupalcode.org/project/media_gallery.git/commit/6a94da6

Status:Fixed» Closed (fixed)

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

I updated from 7.x-1.x to 7.x-2.x-dev (2014-Jan-31 version) and experience the same issues. Each time I try to open a gallery, I get these errors :

Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
Notice: Undefined property: stdClass::$media_gallery_file in media_gallery_node_load() (line 254 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
Warning: array_filter() expects parameter 1 to be array, null given in media_gallery_view() (line 319 van D:\HostingSpaces\xyz\domainname\wwwroot\sites\all\modules\media_gallery\media_gallery.module).
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7721 van D:\HostingSpaces\xyz\domainname\wwwroot\includes\common.inc).

Looking at media_gallery.install it looks like patch #13 is not included. Can I safely apply the patch to this new version? (Drupal 7.26)

It looks like I messed up the original commit - I'm sorry guys.

I have fixed it: http://drupalcode.org/project/media_gallery.git/commit/65cc212