Verified Commit 74761ea1 authored by Andrei Mateescu's avatar Andrei Mateescu
Browse files

task: #3584098 Early return in NodeAccessGrantsCacheContext when there are no grants

By: catch
(cherry picked from commit f0284b7d)
parent 4b7913fb
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ public static function getLabel() {
   * {@inheritdoc}
   */
  public function getContext($operation = NULL) {
    // If there are no grants at all, then always return all.
    if (!\Drupal::moduleHandler()->hasImplementations('node_grants')) {
      return 'all';
    }
    // If the current user either can bypass node access then we don't need to
    // determine the exact node grants for the current user.
    if ($this->user->hasPermission('bypass node access')) {
+3 −3
Original line number Diff line number Diff line
@@ -180,10 +180,10 @@ public function testCacheContext(): void {
    // Uninstall the node_access_test module.
    \Drupal::service('module_installer')->uninstall(['node_access_test']);
    $this->assertUserCacheContext([
      0 => 'view.all',
      0 => 'all',
      $this->adminUser->id() => 'all',
      $this->accessUser->id() => 'view.all',
      $this->noAccessUser->id() => 'view.all',
      $this->accessUser->id() => 'all',
      $this->noAccessUser->id() => 'all',
    ]);
  }