Nodes in a view are incorrectly omitted from the view results when optionally joined via Entity Reference with a second node that is not present.
Steps to reproduce:

  1. Ensure these modules are installed: Views 7.x-3.11, Entity Reference 7.x-1.1, TAC 7.x-1.2
  2. Link a primary content type (e.g. Book) via Entity Reference to a second content type (e.g. Author) by adding a field of type Entity Reference. Max number of values: 1. Required: no.
  3. Link the primary content type Book to the Taxonomy Term used by TAC Lite to control permissions.
  4. Ensure at least two Book nodes are present for testing, one linked to an Author and one without an Author defined. Both books should have security set such that they are visible to anonymous users.
  5. Create a view showing Books; display basic Fields such as Title. Verify that both books display for an anonymous user; this functions as expected.
  6. Now add a relationship in the View to Author via Entity Reference. Do not require the relationship. Add a Title field from the Author relationship to the view fields. Test the view *but not as an administrator*. The Book without an Author will not display in the results.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

spheresh’s picture

cherabomb’s picture

Hi spheresh, thanks for the patch, I will try it! I also found this patch to Drupal core that seems related?
"node_access breaks any query that has node table appearing twice with a left join"
https://www.drupal.org/node/1349080#comment-9449897
Kind regards

apetro’s picture

Issue summary: View changes

I have the same problem using TAC Lite with Entity Reference.
When I have a node protected with TAC Lite and with a reference to another node, users without "Bypass content access control " permission cannot see nodes in a view using this relationship unless the reference is not empty.
I have tried this patch, but for me it doesn't work, unfortunately.

apetro’s picture

Issue summary: View changes
spheresh’s picture

Status: Active » Needs work

This patch really needs work, unfortunately.
P.S. I have a new version and I'll try to upload new version in the nearest future.

apetro’s picture

It's a good news that someone is working on this patch again. I'm in trouble because this issue is blocking for my project and it forces me to find other technical solutions for content access... and TAC Lite is optimal for my needs!
If it is possible, I would like to try this new code.

apetro’s picture

I looked at the code, but it seems to me that patch modifies term visibility, not node visibility in Views.
For me, solution supposed by cherabomb https://www.drupal.org/node/1349080#comment-9449897 fixes this issue!
Visibility problem seems a core problem, not a TAC Lite problem.

spheresh’s picture

Yep. Looks like, tac_lite query_term_access_alter function can be deleted completely, if the https://www.drupal.org/node/1349080#comment-9449897 patch has been applied. I will test it on my project. Thanks.

apetro’s picture

Module does need tac_lite_query_term_access_alter function to hide terms that user hasn't right to select (with "Visibility" option selected in module configuration). It's a very useful function: user cannot misunderstand which term can select.
From code and information I have seen, TAC Lite has nothing to do with this issue and it doesn't need code modification.

apetro’s picture

Status: Needs work » Closed (won't fix)
MrPeanut’s picture

Status: Closed (won't fix) » Closed (works as designed)

Just clarifying that this isn't an issue with TAC Lite.

This patch appears to fix the issue for Drupal 7 (although I would read some of the comments since it's not RTBC as of this post): #1349080-282: node_access filters out accessible nodes when node is left joined

apetro’s picture

@MrPeanut
You're right, Status wasn't appropriate.
TAC Lite has nothing to do with this issue and work continues on Drupal core: https://www.drupal.org/node/1349080