function node_access_needs_rebuild

Same name in other branches
  1. 7.x modules/node/node.module \node_access_needs_rebuild()
  2. 9 core/modules/node/node.module \node_access_needs_rebuild()
  3. 10 core/modules/node/node.module \node_access_needs_rebuild()
  4. 11.x core/modules/node/node.module \node_access_needs_rebuild()

Toggles or reads the value of a flag for rebuilding the node access grants.

When the flag is set, a message is displayed to users with 'access administration pages' permission, pointing to the 'rebuild' confirm form. This can be used as an alternative to direct node_access_rebuild calls, allowing administrators to decide when they want to perform the actual (possibly time consuming) rebuild.

When unsure if the current user is an administrator, node_access_rebuild() should be used instead.

Parameters

$rebuild: (optional) The boolean value to be written.

Return value

bool|null The current value of the flag if no value was provided for $rebuild. If a value was provided for $rebuild, nothing (NULL) is returned.

See also

node_access_rebuild()

Related topics

6 calls to node_access_needs_rebuild()
node_access_rebuild in core/modules/node/node.module
Rebuilds the node access database.
node_help in core/modules/node/node.module
Implements hook_help().
node_modules_installed in core/modules/node/node.module
Implements hook_modules_installed().
node_modules_uninstalled in core/modules/node/node.module
Implements hook_modules_uninstalled().
node_update_8401 in core/modules/node/node.install
Run a node access rebuild, if required.

... See full list

File

core/modules/node/node.module, line 1210

Code

function node_access_needs_rebuild($rebuild = NULL) {
    if (!isset($rebuild)) {
        return \Drupal::state()->get('node.node_access_needs_rebuild') ?: FALSE;
    }
    elseif ($rebuild) {
        \Drupal::state()->set('node.node_access_needs_rebuild', TRUE);
    }
    else {
        \Drupal::state()->delete('node.node_access_needs_rebuild');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.