Steps to reproduce.

1. Create a node reference field (with module References) in a ct eg. pages.
2. On pages display settings change the format to Rendered node, then set View mode: Media gallery block
3. Add a new page content references to a media gallery node.

When view this node, will get this:

Notice: Undefined index: file in media_gallery_field_formatter_view() (line 92 of /home/panparks/public_html/sites/all/modules/contrib/media_gallery/media_gallery.fields.inc).
Notice: Trying to get property of non-object in media_gallery_field_formatter_view() (line 108 of /home/panparks/public_html/sites/all/modules/contrib/media_gallery/media_gallery.fields.inc).
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7389 of /home/panparks/public_html/includes/common.inc).

This is because the file object isn't loaded in the field items in media_gallery_field_formatter_view().

Comments

szantog’s picture

Status:Active» Needs review
StatusFileSize
new849 bytes

Now, I'm building a real complex system with ds, latest dev version of media, and have no time to try this in a fresh, unpatched system. But I think, the bug isn't in connection with that. If can't reproduce on a clean install, I will investigate more, but if I'm right, this patch solves it.

szantog’s picture

StatusFileSize
new885 bytes

Sorry, wrong trying was attached.

andorraclaim’s picture

Status:Needs review» Reviewed & tested by the community

Tested and fixed my issue when creating a view using the media gallery formatter. Great job.

Moloc’s picture

Status:Reviewed & tested by the community» Needs work

There seems to be something wrong. If i apply your patch, the last two images in a gallery are always the same.

Example:
A gallery (and each pager) have 3 images. After applying your patch, image one and two is shown, but the third image is the same as the second.

Using var_dump on the $items array, everything seems to be fine, except that the last array is a reference (i assume, because you use the reference in the foreach-loop). This issue can be fixed by using unset($item); after $file = $item['file'];. (Or is there a better solution?)

There is also another bug-report, which conflicts with your patch. See #1433558: EntityMalformedException when media gallery files no longer exist in the {file_managed} table.

Moloc’s picture

Status:Needs work» Postponed (maintainer needs more info)

I am no longer able to reproduce this issue with beta8.
Is this issue still valid for you? If so, please provide step by step information, how to reproduce.
(Note: you are using media 1.x?)

Moloc’s picture

Status:Postponed (maintainer needs more info)» Fixed

If this is still an issue for you, it is fixed with #1391332: Support file field as well as deprecated media asset field

Status:Fixed» Closed (fixed)

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