Loading core/modules/node/node.permissions.yml +4 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ revert all revisions: delete all revisions: title: 'Delete all revisions' description: 'To delete a revision, you also need permission to delete the content item.' rebuild node access permissions: title: 'Rebuild content access permissions' description: 'Trigger a content access permission rebuild. This can be a potentially long and disruptive process.' restrict access: true permission_callbacks: - \Drupal\node\NodePermissions::nodeTypePermissions core/modules/node/node.post_update.php +14 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\node\NodeTypeInterface; use Drupal\user\RoleInterface; /** * Implements hook_removed_post_updates(). Loading Loading @@ -45,3 +46,16 @@ function node_post_update_create_promote_base_field_overrides(&$sandbox = []): v return $changed; }); } /** * Grants a new permission for rebuilding node access permissions. */ function node_post_update_add_rebuild_permission_to_roles(?array &$sandbox = NULL): void { \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role): bool { if ($role->isAdmin() || !$role->hasPermission('administer nodes')) { return FALSE; } $role->grantPermission('rebuild node access permissions'); return TRUE; }); } core/modules/node/node.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -163,4 +163,4 @@ node.configure_rebuild_confirm: defaults: _form: '\Drupal\node\Form\RebuildPermissionsForm' requirements: _permission: 'administer nodes' _permission: 'rebuild node access permissions' core/modules/node/src/Hook/NodeHelpHooks.php +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ public function help($route_name, RouteMatchInterface $route_match): ?string { // Remind site administrators about the {node_access} table being flagged // for rebuild. We don't need to issue the message on the confirm form, or // while the rebuild is being processed. if ($route_name != 'node.configure_rebuild_confirm' && $route_name != 'system.batch_page.html' && $route_name != 'help.page.node' && $route_name != 'help.main' && \Drupal::currentUser()->hasPermission('administer nodes') && node_access_needs_rebuild()) { if ($route_name != 'node.configure_rebuild_confirm' && $route_name != 'system.batch_page.html' && $route_name != 'help.page.node' && $route_name != 'help.main' && \Drupal::currentUser()->hasPermission('rebuild node access permissions') && node_access_needs_rebuild()) { if ($route_name == 'system.status') { $message = $this->t('The content access permissions need to be rebuilt.'); } Loading core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ protected function setUp(): void { 'administer site configuration', 'access administration pages', 'access site reports', 'administer nodes', 'rebuild node access permissions', ]); $this->drupalLogin($this->adminUser); Loading Loading
core/modules/node/node.permissions.yml +4 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ revert all revisions: delete all revisions: title: 'Delete all revisions' description: 'To delete a revision, you also need permission to delete the content item.' rebuild node access permissions: title: 'Rebuild content access permissions' description: 'Trigger a content access permission rebuild. This can be a potentially long and disruptive process.' restrict access: true permission_callbacks: - \Drupal\node\NodePermissions::nodeTypePermissions
core/modules/node/node.post_update.php +14 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ use Drupal\Core\Config\Entity\ConfigEntityUpdater; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\node\NodeTypeInterface; use Drupal\user\RoleInterface; /** * Implements hook_removed_post_updates(). Loading Loading @@ -45,3 +46,16 @@ function node_post_update_create_promote_base_field_overrides(&$sandbox = []): v return $changed; }); } /** * Grants a new permission for rebuilding node access permissions. */ function node_post_update_add_rebuild_permission_to_roles(?array &$sandbox = NULL): void { \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'user_role', function (RoleInterface $role): bool { if ($role->isAdmin() || !$role->hasPermission('administer nodes')) { return FALSE; } $role->grantPermission('rebuild node access permissions'); return TRUE; }); }
core/modules/node/node.routing.yml +1 −1 Original line number Diff line number Diff line Loading @@ -163,4 +163,4 @@ node.configure_rebuild_confirm: defaults: _form: '\Drupal\node\Form\RebuildPermissionsForm' requirements: _permission: 'administer nodes' _permission: 'rebuild node access permissions'
core/modules/node/src/Hook/NodeHelpHooks.php +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ public function help($route_name, RouteMatchInterface $route_match): ?string { // Remind site administrators about the {node_access} table being flagged // for rebuild. We don't need to issue the message on the confirm form, or // while the rebuild is being processed. if ($route_name != 'node.configure_rebuild_confirm' && $route_name != 'system.batch_page.html' && $route_name != 'help.page.node' && $route_name != 'help.main' && \Drupal::currentUser()->hasPermission('administer nodes') && node_access_needs_rebuild()) { if ($route_name != 'node.configure_rebuild_confirm' && $route_name != 'system.batch_page.html' && $route_name != 'help.page.node' && $route_name != 'help.main' && \Drupal::currentUser()->hasPermission('rebuild node access permissions') && node_access_needs_rebuild()) { if ($route_name == 'system.status') { $message = $this->t('The content access permissions need to be rebuilt.'); } Loading
core/modules/node/tests/src/Functional/NodeAccessRebuildNodeGrantsTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ protected function setUp(): void { 'administer site configuration', 'access administration pages', 'access site reports', 'administer nodes', 'rebuild node access permissions', ]); $this->drupalLogin($this->adminUser); Loading