I have a Views block that appears on certain pages. There are no restrictions on who can view the contents of the view, but it disappears on some pages, for anonymous users, when I enable Nodeaccess.

(Yes, I have rebuilt Nodeacess permissions; that didn't help.)

The view displays two fields from a published Banner node.

It should appear on appropriate node pages when the page's node contains a reference to the Banner node.

For non-node pages, like Views pages, I've set up a block for the Banner view with a pre-configured default value specifying which Banner node to show.

So, for example, if there's a Fruits banner node and a Vegetables banner node, the Grapes product page would have a reference to the Fruits banner in its Section field, and the Peas product page would have a reference to the Vegetables banner node in its Section field. This works fine, with or without Nodeaccess enabled.

Then, there's a Show All Vegetables page defined in Views; as a View, that wouldn't have any banner, so I've set up a Block display for that view. The Block display has a default value of [the nid of the Vegetables banner], and the block is configured to appear on the example.com/show-all-vegetables URL. Before enabling Nodeaccess, this worked great; after enabling Nodeaccess, anonymous visitors no longer see the block on the Show All Vegetables Views page.

Before I installed Nodeaccess, this all worked perfectly.

After installing Nodeaccess, the Vegetable banners show up on the individual Vegetable node pages (the Peas page and the Carrots page), but NOT on the Show All Vegetables Views page.

I have checked all the permissions carefully - the View is set to be visible by all users; the Block is set to be visible by all users. An anonymous user can view the actual Vegetables Banner node itself with no problem. And again - the output from the block DOES appear on individual Vegetable pages... just not on the Views pages, where the only difference is that I'm passing the default value in the Contextual Filter pane.

Any suggestions?

Thanks!

Issue fork nodeaccess-2577307

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kristi Wachter created an issue. See original summary.

dhaneesh88’s picture

I am also having same issue. Please help ?

nerdcore’s picture

Priority: Normal » Critical

Same here. I have a block display in a View which aggregates up to 4 nodes to be displayed on the site's front page. Works fine without Node Access, but as soon as the module gets enabled it causes the View to display the "No Results Behavior" for anonymous visitors.

Marking this Critical, as it will stop me from deploying this module in a production site.

nerdcore’s picture

MaxMendez’s picture

I have a similar problem, when the module is enabled, the results of a view with a not require relationship stop displaying to users.

alison’s picture

Thanks @Kristi Wachter and everybody for the report and details.

If you're still experiencing the problem (anyone), could you please confirm that you're using the latest 7.x version of nodeaccess (just in case)?

Additionally, @MaxMendez, could you please expand on what you mean about having a not-required relationship on your view? (And/or maybe share more details about your use case, like the original report?)

alison’s picture

Status: Active » Postponed (maintainer needs more info)

Hi folks! I'm going to postpone the issue for now -- please see comment #6 for more info.

danielstrum’s picture

I think I am having this same issue:
Drupal 7.71
NodeAccess: 7.x-1.8
Views: 7.x-3.24

I have a Views Slideshow on my homepage. Some of the items in the slider have a "Read More" button that is created through a node reference field on my content type "Frontpage Slide". The field is not required. This has worked for years. It is configured so, if the node reference is empty, there is no button but if it is populated, the button shows. When I enable the NodeAccess module, the slides with an empty node reference are no longer visible. If logged in as an admin, they load.

This (great) module does exactly what I need but I can not use it with this issue. Please let me know if there is any way I can help work through this (I am not a coder). Thanks.

kevinhbruce’s picture

I'm having this same issue.
Drupal 9.3.3
NodeAccess: 8.x-1.1
Views: 9.3.3

Views that show featured content on our public pages were empty when not logged in, but appear when logged in. One user was saying at one point all views in the side column were empty, but some returned when they refreshed the page (I had just cleared the Drupal cache). I was able to confirm the one she said was gone wasn't there.

I tried to make all content types viewable by all roles, but that didn't fix it. I uninstalled nodeaccess, and that fixed it.

codersrini’s picture

I have the same issue.
Drupal 9.3.3
NodeAccess: 8.x-1.1

When I enabled the nodeaccess module and rebuilt the permissions, the view blocks (some basic listing items from a content type) stopped working. Upon debugging, nodeaccess module alters the view query and adds additional sub queries. These subqueries cause the issue (see below).

{ORIGINAL VIEW QUERY} AND (EXISTS (SELECT "na"."nid" AS "nid"
FROM
"node_access" "na"
WHERE ((("gid" IN ('0')) AND ("realm" = 'all')) OR (("gid" IN ('2')) AND ("realm" = 'nodeaccess_rid')) OR (("gid" IN ('14')) AND ("realm" = 'nodeaccess_uid')) OR (("gid" IN ('14')) AND ("realm" = 'nodeaccess_author'))) AND ("na"."grant_view" >= '1') AND (("node_field_data"."nid" = "na"."nid")))) AND (EXISTS (SELECT "na"."nid" AS "nid"
FROM
"node_access" "na"
WHERE ((("gid" IN ('0')) AND ("realm" = 'all')) OR (("gid" IN ('2')) AND ("realm" = 'nodeaccess_rid')) OR (("gid" IN ('14')) AND ("realm" = 'nodeaccess_uid')) OR (("gid" IN ('14')) AND ("realm" = 'nodeaccess_author'))) AND ("na"."grant_view" >= '1')

Uninstalling the nodeaccess module solved the issue.
Now, I have to look for some other module like content_access, node_view_permissions .... to restrict my nodes for anonymous users.

andresrc made their first commit to this issue’s fork.

alison’s picture

Hi all,

@danielstrum I know it's been ages, are you still dealing with this issue on the 7.x version, or have you moved on?

@kevinhbruce and @codersrini Please check the issue queue for 8.x issues in case someone has already reported the bug, and if not, please create a new issue -- this is just a process/best practice thing, we need to work on 7.x and 8.x issues separately. (I can't promise I'll be able to solve the problem, but your best bet for getting help is to create an issue for the 8.x version of the module.)

Thank you!

danielstrum’s picture

Hi... I can't remember how I worked around this but it is no longer an issue for me. Thanks for checking in.

codersrini’s picture

@alisonjo315 - we got our view blocks working by disabling SQL rewriting in Query settings. Others may try this option. This has worked for us. Our requirement was to show some basic information about the restritricted node details like (title, image in a card) on a landing page (say overview) and restrict the node detail page for anonymous users when the user clicks the card from the landing page.

Just a thought: Nodeaccess module may skip the restrictions in a view block, only if the View Block Access is set as Unrestricted

Thanks a lot for this great module.

alison’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

@danielstrum @codersrini Thank you for your replies, I'm glad things worked out!

Great tip about disabling SQL rewriting, I think that's not suuuuper uncommon to have to do when you're using modules that manipulate access to content? -- I would welcome an issue + patch to update the module README with a generic tip that when using nodeaccess and views, you may need to disable SQL rewriting for the access settings provided by nodeaccess to take effect (instead of normal core access functionality, and/or to fix overlapping access control functionality between core and nodeaccess).

I'm closing this issue. Thanks again!