function node_access_rebuild

Same name and namespace in other branches
  1. 11.x core/modules/node/node.module \node_access_rebuild()
  2. 10 core/modules/node/node.module \node_access_rebuild()
  3. 9 core/modules/node/node.module \node_access_rebuild()
  4. 8.9.x core/modules/node/node.module \node_access_rebuild()
  5. 7.x modules/node/node.module \node_access_rebuild()

Rebuilds the node access database.

This rebuild is occasionally needed by modules that make system-wide changes to access levels. When the rebuild is required by an admin-triggered action (e.g module settings form), calling node_access_needs_rebuild(TRUE) instead of node_access_rebuild() lets the user perform changes and actually rebuild only once done.

Note : As of Drupal 6, node access modules are not required to (and actually should not) call node_access_rebuild() in hook_install/uninstall anymore.

Parameters

bool $batch_mode: (optional) Set to TRUE to process in 'batch' mode, spawning processing over several HTTP requests (thus avoiding the risk of PHP timeout if the site has a large number of nodes). hook_update_N() and any form submit handler are safe contexts to use the 'batch mode'. Less decidable cases (such as calls from hook_user(), hook_taxonomy(), etc.) might consider using the non-batch mode. Defaults to FALSE. Calling this method multiple times in the same request with $batch_mode set to TRUE will only result in one batch set being added.

Deprecated

in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service('\Drupal\node\NodeAccessRebuild')->rebuild($batch_mode) instead.

See also

node_access_needs_rebuild()

https://www.drupal.org/node/3534610

File

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

Code

function node_access_rebuild($batch_mode = FALSE) : void {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(\'\\Drupal\\node\\NodeAccessRebuild\')->rebuild($batch_mode) instead. See https://www.drupal.org/node/3534610', E_USER_DEPRECATED);
  \Drupal::service(NodeAccessRebuild::class)->rebuild($batch_mode);
}

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