Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
OG 7.x-2.1
OG Access control NOT activated
Strict node access permissions NOT set
Domain Access 7.x-3.9
In several node views I use the "OG membership of node" and "Group node of OG membership" relationships.
"Requiere this relationship" is NOT set.
Output is "Teasers".
Non group content is not listed to normal users.
All roles which have the "Bypass content access control" permission do see non group content. As soon as I grant this permission to any role the non group content appears.
As soon as I remove both relationships non group content is shown to all users as expected.
Any idea?
Comments
Comment #1
creando sensaciones CreditAttribution: creando sensaciones commentedI was able to identity the cause in the query.
"OG membership of node" or "Group node of OG membership" are adding this condition to the query:
It requieres an entry in the node_og_membership table even if the relationship is optional.
Comment #2
creando sensaciones CreditAttribution: creando sensaciones commentedI solved the issue by checking the 'Query settings' > 'Disable SQL rewriting' checkbox.
Still I would appreciate feedback about the OG access control added to the query. Should it be like that, and will it be solved in future versions?
Comment #3
Dustin@PI CreditAttribution: Dustin@PI commentedAnyone stumbling on this problem ... this issue is probably the cause: #1349080: node_access filters out accessible nodes when node is left joined
Comment #4
golddragon007 CreditAttribution: golddragon007 commentedI have the same problem with og 2.7. I debugged a lot, than I find the 'real' solution, but I can't do it (I can't find the generator code, ect.).
You get a similar code like this from your second join (which is an another join):
This code goes to the wrong place, it's need to be go to the end of the join and it will work correctly. Reason (which I find) the
node_og_membership.nid
is alway NULL in the main select ('outer' select) so it will always false thenode_og_membership.nid = na.nid
.So, if you join a table with the main select, you need to put after the
WHERE
, if you join a table which was join, you need to put after THAT join'sON
, which was the last join in the 'hierarchy'.i.e.
Now (original):
Need to be:
Comment #5
golddragon007 CreditAttribution: golddragon007 commentedI debugged a little more with xdebug and I agree with @Dustin@PI. This in not an OG bug, it's a views bug. In the https://www.drupal.org/node/1349080#comment-9449897 comment theres a patch which exactly worked and solved the problem, which I found too.