Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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().
Comment | File | Size | Author |
---|---|---|---|
#2 | 1300144_2_missing_file_object.patch | 885 bytes | szantog |
#1 | 1300144_missing_file_object.patch | 849 bytes | szantog |
Comments
Comment #1
szantog CreditAttribution: szantog commentedNow, 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.
Comment #2
szantog CreditAttribution: szantog commentedSorry, wrong trying was attached.
Comment #3
justadropofwater CreditAttribution: justadropofwater commentedTested and fixed my issue when creating a view using the media gallery formatter. Great job.
Comment #4
Moloc CreditAttribution: Moloc commentedThere 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.
Comment #5
Moloc CreditAttribution: Moloc commentedI 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?)
Comment #6
Moloc CreditAttribution: Moloc commentedIf this is still an issue for you, it is fixed with #1391332: Support file field as well as deprecated media asset field