Just spotted that there is actually a bug in the way we load entities when the " Additional access checks on result entities" option is enabled for a view. This is the code in question:

      if (!empty($this->options['entity_access']) && ($entity_type = $this->index->getEntityType())) {
        $entity = entity_load($entity_type, array($id));
        if (!entity_access('view', $entity_type, $entity[$id])) {
          continue;
        }
      }

$id here is the datasource's item ID for the item – but that doesn't need to be the same as the item's entity ID. E.g., if you have a multilingual index created through the Search API ET module, the item IDs also contain the items' language codes, thus making them invalid when used as entity IDs. So, in such cases, the above code won't work and all items would be rejected, an empty result displayed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Status: Active » Needs review
FileSize
786 bytes

Patch attached.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

I think this fixed a WSOD that I traced back to search_api_index which I found from this: http://drupal.stackexchange.com/a/15649/3998

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great to hear, thanks for testing!
Committed.

  • drunken monkey committed fe7232b on 7.x-1.x
    Issue #2412895 by drunken monkey: Fixed entity load for Views entity...
drunken monkey’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)

Ah, almost forgot, we should of course also include this in the D8 version. (Just copying it verbatim should be enough, since that part is currently commented out (for some reason) anyway.)

drunken monkey’s picture

Issue tags: +Novice
dragos-dumi’s picture

Status: Patch (to be ported) » Needs review
FileSize
960 bytes

Ported the patch for 8.x-1.x branch.

drunken monkey’s picture

OK, "verbatim" was a bit optimistic of me, sorry about that. Actually, those methods have changed a bit (and there is now an access() method on entities, so that line was actually correct already).
Still, thanks for your help!

Also, seeing the code again, let's try enabling it? Does it blow up horribly, or why was it commented out?

drunken monkey’s picture

Status: Needs review » Fixed

Hm, seems to be fine. So, committed.
Thanks again for your help!

Status: Fixed » Closed (fixed)

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