Document issues with too many realms/grants in node access hooks

Created on 14 January 2011, over 13 years ago
Updated 9 August 2023, about 1 year ago

node_access() builds queries based on hook_node_access_grants() and hook_node_access_records().

These queries can get huge if there are large numbers of gids and realms. EclipseCG was discussing such a problem on an actual site today in IRC, in fact.

We need to document this limitation of the grant/realm system, and suggest that if your system would have a lot of realms/grants, not to use hook_node_access_grants() and hook_node_access_records() but instead to use hook_node_access() and build your own record-keeping and queries, which would probably also involve a hook_node_update() and other hooks to trigger saving the node access info when the node is created/updated.

We should put a note on the the grants/records hooks, and more detailed information about this suggestion on http://api.drupal.org/api/drupal/modules--node--node.module/group/node_a...

πŸ› Bug report
Status

Closed: won't fix

Version

8.0 ⚰️

Component
DocumentationΒ  β†’

Last updated 1 minute ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States jhodgdon Spokane, WA, USA

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

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.

  • πŸ‡ͺπŸ‡ͺEstonia ragnarkurm

    As Google search is leading here, more people might be looking for help regarding "too many realms/grants", I added the info here. Encountered the issue with the permissions_by_term module, but the problem is more generic. Created also a core patch to alleviate the problem. The core patch is in the module issue queue since I understand that core maintainers are not willing to optimize NodeGrantDatabaseStorage::access(), and pointing toward using more specific hooks.

    https://www.drupal.org/project/permissions_by_term/issues/3380033 πŸ“Œ Performance degradation Postponed: needs info

    The patch in the issue takes care of monster select queries to the node_access table per node, but not for views. It is still a noticeable improvement in terms of speed.

Production build 0.71.5 2024