Rebuild permissions on install and uninstall

Created on 28 January 2024, 10 months ago
Updated 19 March 2024, 8 months ago

Problem/Motivation

Upon enabling the 'unpublished_node_permissions' module in a project with existing nodes, a message prompts the developer with: "The content access permissions need to be rebuilt."

Steps to reproduce

  1. Have a project with existing nodes.
  2. Enable the latest 'unpublished_node_permissions' module.
  3. Encounter the message: "The content access permissions need to be rebuilt."

Proposed resolution

A potential solution involves incorporating a hook install to automatically trigger the permission rebuild during installation.
Similarly, the uninstall process can be enhanced by including a hook uninstall to perform the necessary rebuild.

/**
 * Implements hook_install().
 */
function unpublished_node_permissions_install() {
  node_access_rebuild(TRUE);
}

/**
 * Implements hook_uninstall().
 */
function unpublished_node_permissions_uninstall() {
  node_access_rebuild(TRUE);
}
πŸ“Œ Task
Status

Fixed

Version

1.4

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany vesnag

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

Merge Requests

Comments & Activities

  • Issue created by @vesnag
  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    Hi @vesnag,

    Thanks for the MR.

  • Status changed to Fixed 10 months ago
  • Status changed to Fixed 10 months ago
  • πŸ‡ΊπŸ‡ΎUruguay gonzalo2683

    Hello,

    I've been using module and would like to discuss the inclusion of an additional `hook_update_N()` that runs during module updates. I have specific concerns regarding the performance impact this additional process might have, especially on sites with a large number of nodes.

    Including an update process that also triggers a permissions rebuild concerns me, as sites which may not need this update are forced to undergo a potentially costly process across a large number of nodes.

    My questions and concerns are as follows:

    1. What is the justification behind the inclusion of the additional `hook_update_N()`, aside from the install and uninstall processes? I understand there may be valid reasons, but I would like to better understand the context and necessity from the development team's perspective.

    2. Has the performance impact of this additional process been considered, especially since the primary updates seem intended for installation and uninstallation scenarios? Recommendations for mitigating impacts on sites that may not directly benefit from this update would be highly appreciated.

    Thank you for your time, and I'm open to further discussion on this topic.

    Best regards,

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    Hi there,

    node grants were added in the 1.3 version of the module.

    there are two cases:
    1. the module was updated on the site (was previously enabled). in that case, we should use an update hook to rebuild node grants.
    2. the module was NOT installed on the site. in that case, we should rebuild node grants via an install hook (an update hook won't be executed/triggered).

Production build 0.71.5 2024