Problem/Motivation

When ever any change is made to a User Role, even simply renaming the Role, the update hook is called and the a node access rebuild flag is set. Node access rebuild is an incredibly time consuming process for large websites with thousands of node.


The node access table only needs rebuilding if permissions have changed, and only the permissions that this module uses.

Steps to reproduce

Edit a Role and change it's name, not even changing a permission.
You will now have the warning message to rebuild all of the node access permissions even though no permissions have changed.

Proposed resolution

Only call node_access_needs_rebuild(TRUE); if a permission has changed in a role that will effect any of the filters that this module adds.


I have patched the views_node_access_filter_user_role_update(EntityInterface $entity) method to only call the rebuild function if a role has either gained or lost one of the following permissions:

  • 'edit any [TYPE] content'
  • 'edit own [TYPE] content'
  • 'revert [TYPE] revisions'

This should reduce the amount of times that the node access table is flagged to rebuild.

I'm not sure if that is the correct set of permissions to monitor?

CommentFileSizeAuthor
#2 3383350-node_access_rebuild.patch2.13 KBaltcom_neil
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:

Comments

Altcom_Neil created an issue. See original summary.

altcom_neil’s picture

StatusFileSize
new2.13 KB
akshay.singh’s picture

Version: 8.x-1.0-beta2 » 8.x-1.x-dev
Status: Active » Needs review
altcom_neil’s picture

Issue summary: View changes

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

prudloff’s picture

Status: Needs review » Needs work

I created a MR from the patch to make this easier to review.
phpcs reports a problem: https://git.drupalcode.org/project/views_node_access_filter/-/jobs/4764202