[So far, I can't find any other posts on this problem. I _think_ the fix will ultimately have to be in the Views module, but I'm posting in both Views and Relation because it's relevant to both and I don't really know where to fix it.]

In views that contain relations, any node that doesn't have a value for a relation doesn't show up in the view at all, IF the account loading the view doesn't have the 'bypass content access control' permission. This happens even if 'require this relation' isn't checked. I have managed to trace the problem here:

SELECT
...
LEFT JOIN field_data_endpoints field_data_endpoints ON
node.nid = field_data_endpoints.endpoints_entity_id AND
(field_data_endpoints.bundle = 'provides' AND field_data_endpoints.endpo
ints_entity_type = 'node' AND field_data_endpoints.endpoints_r_index = '1')
LEFT JOIN field_data_endpoints field_data_endpoints2 ON
field_data_endpoints.entity_id = field_data_endpoints2.entity_id AND
(field_data_endpoints2.endpoints_entity_type = 'node' AND field_data_end
points2.endpoints_r_index != field_data_endpoints.endpoints_r_index AND 1 = '1'
)
LEFT JOIN node node_node ON
field_data_endpoints2.endpoints_entity_id = node_node.nid AND field_data
_endpoints2.endpoints_entity_type = 'node'
...
WHERE
...
( EXISTS (
SELECT na.nid AS nid
FROM node_access na
WHERE (
((na.gid = '0') AND (na.realm = 'all')) OR ((na.gid = '4
6') AND (na.realm = 'content_access_author')) OR ((na.gid = '2') AND (na.realm =
'content_access_rid')) OR
((na.gid = '4') AND (na.realm = 'content_access_rid'))
)
AND (na.grant_view >= '1') AND (node_node.nid = na.nid)
))

That EXISTS clause will fail if there are no permission rows for the other endpoint because the other endpoint is NULL. I have verified that replacing the EXISTS line with:
...
( node_node.nid IS NULL OR EXISTS (
...
produces the desired behavior (the row shows up, with blanks for the non-existent relations). What I haven't figured out is exactly where to even consider modifying the code to fix this. Most of the EXISTS clause is being generated in views/modules/node/views_handler_filter_node_access.inc, in views_handler_filter_node_access::query(), but I'm not sure about the EXISTS itself. Does anyone have any pointers to previous work on this, or where to patch the code?

Comments

purplezephyr’s picture

P.S. https://drupal.org/node/2064445 is the issue I posted to the Relation queue, for reference.

purplezephyr’s picture

It turns out this is an interaction between Relation, Views, and Content Access, and there's a thread in Content Access. https://drupal.org/node/2020453. I'm going to post there, but any help you can still offer would be greatly appreciated.

kari.nies’s picture

Dear purplezephyr. I am having a very similar problem, though I am not using Content Access. I tried a clean build with the latest drupal and views module and found that the problem only appeared when I introduced the groups access module. When searching Organic Groups queue, I found this post:
https://drupal.org/node/1964246

Follow the link in the last comment to the patch on #89. It seems to have solved the problem for me..

steinmb’s picture

Issue summary: View changes
Priority: Critical » Normal
Status: Active » Postponed

Prob. burred inside #1349080: node_access filters out accessible nodes when node is left joined If so, close this as duplicate?

purplezephyr’s picture

The answer turns out to be this patch (#174) for core:
https://drupal.org/comment/8363849#comment-8363849

h/t vramirez1 in https://drupal.org/comment/8400091#comment-8400091