Skip to content
Snippets Groups Projects

Avoid cache redirect error in NodeAccessControlHandler.

Closed catch requested to merge issue/drupal-3504114:3504114-quick-fix into 11.x
2 files
+ 81
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -223,7 +223,16 @@ protected function checkViewAccess(NodeInterface $node, AccountInterface $accoun
@@ -223,7 +223,16 @@ protected function checkViewAccess(NodeInterface $node, AccountInterface $accoun
return NULL;
return NULL;
}
}
 
// When access is granted due to the 'view own unpublished content'
 
// permission and for no other reason, node grants are bypassed. However,
 
// to ensure the full set of cacheable metadata is available to variation
 
// cache, additionally add the node_grants cache context so that if the
 
// status or the owner of the node changes, cache redirects will continue to
 
// reflect the latest state without needing to be invalidated.
$cacheability->addCacheContexts(['user']);
$cacheability->addCacheContexts(['user']);
 
if ($this->moduleHandler->hasImplementations('node_grants')) {
 
$cacheability->addCacheContexts(['user.node_grants:view']);
 
}
if ($account->id() != $node->getOwnerId()) {
if ($account->id() != $node->getOwnerId()) {
return NULL;
return NULL;
}
}
Loading