Getting different results for admin versus non-admin user on view when there is a relationship I have a view that shows the two newest articles with specific taxonomy rules. We got a new requirement to now exclude articles that are linked via entity reference.

So I added the relationship for referencing entities. With just the relationship in place and no filters added, non-admin users only see articles that are related (the relationship is not set to required).

When I add the filter that node ID of the related (referencing) articles should be NULL, non-admin users see nothing, but admin users see the results as they should be.

What can explain the discrepancy and what can fix it?

Drupal 7
Seems like this problem is related to this drupal bug https://www.drupal.org/node/1349080 .

Solution: Edit your view > Right column "Advanced" > Query settings: check "Disable Query Rewriting"

Simple explanation for the bug and the solution https://www.drupal.org/node/1276450#comment-10451305, quote the comment below


  Actually, this is a bug, in Drupal core, and there is a fix, in
  #1349080: node_access breaks any query that has node table appearing twice with a left join. It just has not been committed to Drupal core
  yet, because the fix is a bit brittle and may not work in all corner
  cases. It has to do with the node_access system, and any view that
  connects the node table or an entity table multiple times (e.g. via a
  relationship), when there is any access module enabled on the site,
  will trigger it.
  
  Disabling SQL rewriting will bypass the issue, and should be entirely
  safe to do, unless you have some access rules you want to enforce
  (such as products in an OG group that only members of that group
  should be able to see) -- in which case you can usually address that
  by adding your own explicit filter to the view instead of relying on
  the core node access to filter it out for you.
  
  If all your products are public, there's no need for this node_access
  check.


Cheers