Skip to content
Snippets Groups Projects
Commit d83a7742 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2671916 by Berdir, mgoedecke: node_access_rebuild() will never work...

Issue #2671916 by Berdir, mgoedecke: node_access_rebuild() will never work after since entityQuery has now accessCheck default set to true and the grants are deleted beforehand
parent 49d199b3
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -1157,6 +1157,11 @@ function node_access_rebuild($batch_mode = FALSE) {
// quickly.
$entity_query = \Drupal::entityQuery('node');
$entity_query->sort('nid', 'DESC');
// Disable access checking since all nodes must be processed even if the
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
$entity_query->accessCheck(false);
$nids = $entity_query->execute();
foreach ($nids as $nid) {
$node_storage->resetCache(array($nid));
......@@ -1207,6 +1212,11 @@ function _node_access_rebuild_batch_operation(&$context) {
$nids = \Drupal::entityQuery('node')
->condition('nid', $context['sandbox']['current_node'], '>')
->sort('nid', 'ASC')
// Disable access checking since all nodes must be processed even if the
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
->accessCheck(false)
->range(0, $limit)
->execute();
$node_storage->resetCache($nids);
......
......@@ -171,6 +171,22 @@ function testNodeAccessBasic() {
// This user should be able to see all of the nodes on the relevant
// taxonomy pages.
$this->assertTaxonomyPage(TRUE);
// Rebuild the node access permissions, repeat the test. This is done to
// ensure that node access is rebuilt correctly even if the current user
// does not have the bypass node access permission.
node_access_rebuild();
foreach ($this->nodesByUser as $private_status) {
foreach ($private_status as $nid => $is_private) {
$this->drupalGet('node/' . $nid);
$this->assertResponse(200);
}
}
// This user should be able to see all of the nodes on the relevant
// taxonomy pages.
$this->assertTaxonomyPage(TRUE);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment