Add an event or hook that's fired when node access rebuild is completed, or update docs to reflect it's not possible

Created on 31 October 2018, over 6 years ago
Updated 19 March 2025, about 1 month ago

I need to add a special "view all" record (nid 0) into the node_access table. The only appropriate place to insert this special record is when the records are rebuilt.

The documentation on hook_node_grants says this:

Node access records are stored in the {node_access} table and define which grants are required to access a node. There is a special case for the view operation -- a record with node ID 0 corresponds to a "view all" grant for the realm and grant ID of that record. If there are no node access modules enabled, the core node module adds a node ID 0 record for realm 'all'. Node access modules can also grant "view all" permission on their custom realms; for example, a module could create a record in {node_access} with:

...

If you decide to do this, be aware that the node_access_rebuild() function will erase any node ID 0 entry when it is called, so you will need to make sure to restore your {node_access} record after node_access_rebuild() is called.

However, there's currently no way for a contrib module to reliably run code after that rebuild has been completed. I found this old Stack Overflow post about someone asking how to do this, and the only answer indicates you should use an additional form submit handler for the form that most people would use to manually rebuild node access records. However there are other areas that this rebuild would occur where that approach would not work.

This could be solved by firing an event or invoking a hook at the end of the function. Or, if we won't do it, we should update the documentation to say that it's not possible.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

node system

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    From NodeAccessControlHandlerInterface::acquireGrants documentation we have hook_node_access_records and hook_node_access_records_alter is this sufficient?

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    Unfortunately, no. This issue is about node grants, not node access records. Grants are what define the access rules for a node, and access records are what assign individual users the keys to unlock those grants. What we need here is the ability to hook into the process when node access grants are rebuilt, which doesn't exist.

    I created this issue 7 years ago, and I clearly found some kind of workaround, I just don't know what it is!

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA
Production build 0.71.5 2024