Hi,
I've been trying to get this module to work on D9 with the patch from #3114359. It didn't install cleanly but I've manually patched the info.yml to add the version requirements.

When I rebuild permissions, then set permissions for anon to view all basic pages there is no access to any nodes at all. Are there default permissions that should be set that the ones provided by this module override or should they work independently of anything else going on.

I've previously had content_access installed but uninstalled it properly so I don't think that's a problem although possibly worth mentioning.

Many thanks in advance,

CommentFileSizeAuthor
#12 node_view_permissions_language_und.patch661 bytescafuego
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Hitby created an issue. See original summary.

adityasingh’s picture

Title: Moule blocking access to all pages for anon » Module blocking access to all pages for anon
Yazzbe’s picture

upgraded form drupal 8.8 to 8.9 + upgraded Node View Permissions to 1.3

rebuild permissions ... and I have also no page access for anonymous users.

reverting back to 1.2 + restoring a database backup fixed it on D8.9.6

brunodbo’s picture

Component: Documentation » Code
Category: Support request » Bug report
Priority: Normal » Major

I ran into a similar issue today after updating to v8.1.3 of Node View Permissions, and rebuilding node access permissions: some content became inaccessible to authenticated users who had access to the content previously. Downgrading to v8.1.2 + rebuilding node access permissions fixed it.

Using core 8.9.6.

medienverbinder’s picture

I could see the same error when updating to Drupal 8.9.6 and Node View Permissions to 1.3.
On all public pages (anonymous users) I got the error message "Access denied"

The logfile showed the following:

type: access denied
Path: /. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 117 of /core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

The solution from #3 or #4 helped.

jcourtice’s picture

We had a similar issue arise. Group users couldn't view their content via the admin screen. Rolling back to 1.2 solved the issue.

SoCalErich’s picture

+1 for this issue. On Drupal 8.9.6. Had to revert back to Node View Permissions 1.2 and all was well.

AardWolf’s picture

Status: Active » Postponed (maintainer needs more info)

Hi all.
Do you clear the cache?
Is your site multilanguage?
Do you use Workflow module?

Because there's only 2 changes:
1. Add implementation for Workflows and Content Moderation #3011136: Add implementation for Workflows and Content Moderation
2. D9 compatibility #3141235: Automated Drupal Rector fixes

Could you write step by step manual to reproduce issue?
We need to know which permissions is set for content type. It will be helpful.

Yazzbe’s picture

tested on drupal 8.9.7 + node view permissions 1.3 with the same result.

  • clear cache, before AND after drush updb
  • site is multilingual (2 languages installed (NL/EN), While NL is set as default)
  • no workflow module
  • no other node permission modules (but have module field permissions also)
  • clear cache, before AND after rebuilding node permissions

error happens after 'rebuilding permissions' on the status page => no acces for anonymous users any more

SoCalErich’s picture

I currently have 13 languages on my site and am also using content moderation with the Workflow module. I clear the cache and rebuild permissions and clear cache again etc. What's weird is I cant really figure out why it only affects some pages. It's not ALL pages. I dont know what the rhyme or reason is to it, but I definitely start getting Access Denied for some pages. If I revert the module, everything is fine again.

AardWolf’s picture

But what's about permissions on content in Nodes and Node view permissions?

cafuego’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
661 bytes

I've got what I expect is the same issue on one of our websites, which started happening after a node content access rebuild after updating this module from v1.2 to v1.3. Some users, anonymous and authenticated, lost access to some content they were previously able to see.

I traced the access grants queries that Drupal runs, and found what I think is the problem. Drupal generates a node_access query for a given node type with the grant strings view_any_{$type}_content plus view_any_{$type}_{$langcode}_content (for all enabled languages) when determining access.

The node_view_permissions does write those grants records when content has a langcode *or* Language::LANGCODE_NOT_APPLICABLE (zxx) but where it falls over is when the langcode is Language::LANGCODE_NOT_SPECIFIED (und).

In that case, the access query looks for any grants with view_any_{$type}_content but the grants that were written to the node_access table use realm view_any_${type}_und_content, so the query returns an empty result and access is rejected.

You can hotfix that by running this query (after doing a database backup, just in case!)

UPDATE node_access SET realm=REPLACE(realm, '_und_content', '_content') WHERE realm LIKE '%\_und\_content';

And then rebuilding caches. If you then rebuild the access perms, access will disappear again, so don't :-)

A more permanent fix is to write the correct node grants to begin with for any content with Language::LANGCODE_NOT_SPECIFIED. The attached patch does that by treating it the same as other language neutral or untranslated content. It would probably be a good idea to add some tests, to stop this breaking in the future.

cafuego’s picture

Title: Module blocking access to all pages for anon » Module blocking access to all content with Language::LANGCODE_NOT_SPECIFIED

adci_contributor’s picture

Status: Needs review » Fixed

@cafuego
Thank you for investigating issue reason and for patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.