I have an issue with a very specific, but not uncommon use case.
For a specific node of type A I want to list all referenced nodes of type B. These nodes are referenced in an entity relation field.
So I add a table with base_table node and add an entity reference relationship. So far so good, I have my list.
But when I then change my display to be rendered nodes, I have no output.

Debugging this issue I found that it was caused in get_result_entities. Even if I added my entity reference field as a relationship, the relationship in the function was empty and the base table was set to node, and not to the reference fields table.
This caused the foreach loop to not populate the entities array properly because get_field_alias returned the wrong field alias.
I then looked into the entity and entity reference module and found that the get_result_entities was called with a third argument not defined in views_plugin_query_default.inc, namely the field_alias.
I do not understand why the argument isn't defined and can't find anywhere where it's actually used, but I made a patch for views where it uses the provided field_alias argument if it exists, and this fixed my issue.

I might be that the error actually lies in the entity or entity reference module, I would love some feedback on what is going on.

I've attached the patch in case somebody else has had the same headache as me, debugging this issue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dysrama’s picture

ChristianEsbensen’s picture

Refactored for 3.14

jespermb’s picture