When relationship support was added, entity fields were moved to the $row['_entity_properties'] array. However, the line that checks for missing fields was not changed to check this array. This feature simplifies working with some external data sources, so it would be nice if it worked.

CommentFileSizeAuthor
#1 missing-fields-2414367.patch1020 bytesDarren Oh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Darren Oh’s picture

Assigned: Darren Oh » Unassigned
Status: Active » Needs review
FileSize
1020 bytes
Darren Oh’s picture

drunken monkey’s picture

Status: Needs review » Fixed

Thanks for spotting this! Can't believe we missed this …
However, it's actually pretty inconsequential, as far as I can see, as $this->fields will always be an empty array (unless I'm mistaken). As noted in the doc comment of extractFields(), field handlers now load their (missing) data themselves. (They also wouldn't even know how to add fields to a Search API Views query, I guess, since they aren't Search API-specific anymore.)

Which raises the question of why the whole code stayed there in the first place – but I guess we can just leave it there for now and do a better/cleaner job in D8, instead of having to figure out now what parts of that code actually still serve a purpose.

Anyways, patch committed. Thanks again!

Darren Oh’s picture

Thanks for fixing this. It was consequential for me because I am working with an external API which I cannot change. I populated $this->fields by using the view query’s addField method in hook_search_api_views_query_alter(). I suppose I could have overridden the handler for each field type in hook_entity_views_field_handlers_alter() instead, but that seems needlessly complicated.

Status: Fixed » Closed (fixed)

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