.../node/src/Cache/NodeAccessViewGrantsCacheContext.php | 10 +++------- .../node/src/Tests/NodeAccessViewGrantsCacheContextTest.php | 6 +++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/modules/node/src/Cache/NodeAccessViewGrantsCacheContext.php b/core/modules/node/src/Cache/NodeAccessViewGrantsCacheContext.php index a074257..d1944ef 100644 --- a/core/modules/node/src/Cache/NodeAccessViewGrantsCacheContext.php +++ b/core/modules/node/src/Cache/NodeAccessViewGrantsCacheContext.php @@ -49,18 +49,14 @@ public static function getLabel() { public function getContext() { // If the current user either: // - can bypass node access - // - no node access modules exist (no hook_node_grants() implementations) - // - the operation is 'view' and the current user has a global view grant - // (such as a view grant for node ID 0) + // - has a global view grant (such as a view grant for node ID 0) — note + // that this is automatically the case if no node access modules exist (no + // hook_node_grants() implementations) // then we don't need to determine the exact node view grants for the // current user. if ($this->user->hasPermission('bypass node access')) { return 'bypass'; } - if (!count(\Drupal::moduleHandler()->getImplementations('node_grants'))) { - return 'n/a'; - } - if (node_access_view_all_nodes($this->user)) { return 'all'; } diff --git a/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php b/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php index c44dc62..94adac7 100644 --- a/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php +++ b/core/modules/node/src/Tests/NodeAccessViewGrantsCacheContextTest.php @@ -133,10 +133,10 @@ public function testCacheContext() { $this->container->get('module_installer')->uninstall(['node_access_test']); drupal_static_reset('node_access_view_all_nodes'); $this->assertCacheContext([ - 0 => 'n/a', + 0 => 'all', 1 => 'bypass', - 2 => 'n/a', - 3 => 'n/a', + 2 => 'all', + 3 => 'all', ]); }