function node_access_view_all_nodes
Same name and namespace in other branches
- 10 core/modules/node/node.module \node_access_view_all_nodes()
- 9 core/modules/node/node.module \node_access_view_all_nodes()
- 8.9.x core/modules/node/node.module \node_access_view_all_nodes()
- 7.x modules/node/node.module \node_access_view_all_nodes()
Determines whether the user has a global viewing grant for all nodes.
Checks to see whether any module grants global 'view' access to a user account; global 'view' access is encoded in the {node_access} table as a grant with nid=0. If no node access modules are enabled, node.module defines such a global 'view' access grant.
This function is called when a node listing query is tagged with 'node_access'; when this function returns TRUE, no node access joins are added to the query.
Parameters
\Drupal\Core\Session\AccountProxyInterface|null $account: (optional) The user object for the user whose access is being checked. If omitted, the current user is used. Defaults to NULL.
Return value
bool TRUE if 'view' access to all nodes is granted, FALSE otherwise.
Deprecated
in drupal:11.3.0 and is removed from drupal:12.0.0. Use \Drupal::entityTypeManager()->getAccessControlHandler('node')->checkAllGrants() instead.
See also
https://www.drupal.org/node/3038909
node_query_node_access_alter()
1 call to node_access_view_all_nodes()
- NodeAccessTest::testNodeAccessViewAllNodesDeprecation in core/
modules/ node/ tests/ src/ Kernel/ NodeAccessTest.php - @group legacy
2 string references to 'node_access_view_all_nodes'
- drupal_static_reset in core/
includes/ bootstrap.inc - Resets one or all centrally stored static variable(s).
- NodeAccessTest::testNodeAccessViewAllNodesDeprecation in core/
modules/ node/ tests/ src/ Kernel/ NodeAccessTest.php - @group legacy
File
-
core/
modules/ node/ node.module, line 338
Code
function node_access_view_all_nodes($account = NULL) {
@trigger_error('node_access_view_all_nodes() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use \\Drupal::entityTypeManager()->getAccessControlHandler(\'node\')->checkAllGrants(). See https://www.drupal.org/node/3038909', E_USER_DEPRECATED);
// If no modules implement the node access system, access is always TRUE.
if (!\Drupal::moduleHandler()->hasImplementations('node_grants')) {
return TRUE;
}
return \Drupal::entityTypeManager()->getAccessControlHandler('node')
->checkAllGrants($account ?? \Drupal::currentUser());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.