Hi,

In the function "EntityFieldHandlerHelper::extract_property_multiple", if "$property" is an instance of "EntityListWrapper", then a wrong type of the extracted wrappers may be returned.

The reason is that if "$property" contains an empty "$item", then "$type" can not be set properly.

The attachment is a patch to fix this issue.

Regards!

Comments

lchang’s picture

lchang’s picture

Status: Active » Needs review
robbertnl’s picture

Thank you. This patch fixed this issue https://www.drupal.org/node/2190977 for me

ronino’s picture

I have a view that displays nodes with images from field_collection items. If however the node of the last row on the current page doesn't have an image, no images at all are displayed for all the rows. I found that this bug is the cause.

#1 should fix the problem, but still return the wrong type if there are only wrappers with no items.

I attached a patch that should work in any case.

bramvandenbulcke’s picture

Thanks alot! This also fixes https://www.drupal.org/node/2190977 for me.

pq’s picture

Status: Needs review » Reviewed & tested by the community

Fixes the issue for me with no apparent side effects.

sardis’s picture

That's the exact solution i came to with my issue, that's quite similar to #2190977: Search API Product Display does not display images or price using fields.
Fixed my problem as well! Thank you, @Ichang & @Ronino!

dawehner’s picture

Note: I'm not a maintainer of entity API in Drupal 7 at all.
One thing I would though ask, when I would have to look at the patch. Why can't we provide a test for this bugfix?

fago’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Phew, interesting edge case. I agree with dawehner that it would be good to make sure this works properly by adding a test coverage.