summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/node/src/NodeAccessControlHandler.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/node/src/NodeAccessControlHandler.php')
-rw-r--r--core/modules/node/src/NodeAccessControlHandler.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/modules/node/src/NodeAccessControlHandler.php b/core/modules/node/src/NodeAccessControlHandler.php
index 963ab53ded4..7121f62e283 100644
--- a/core/modules/node/src/NodeAccessControlHandler.php
+++ b/core/modules/node/src/NodeAccessControlHandler.php
@@ -223,7 +223,16 @@ class NodeAccessControlHandler extends EntityAccessControlHandler implements Nod
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']);
+ if ($this->moduleHandler->hasImplementations('node_grants')) {
+ $cacheability->addCacheContexts(['user.node_grants:view']);
+ }
if ($account->id() != $node->getOwnerId()) {
return NULL;
}