From c1eca90c5f91326231f9f75d93f3d2086f774517 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Tue, 17 Dec 2024 22:01:53 +0100 Subject: [PATCH] Consistently cache accessibility by current role --- src/Cms/Language.php | 2 +- src/Cms/User.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cms/Language.php b/src/Cms/Language.php index 2bf67ac009..6de9f3a8ba 100644 --- a/src/Cms/Language.php +++ b/src/Cms/Language.php @@ -307,7 +307,7 @@ public function exists(): bool public function isAccessible(): bool { static $accessible = []; - $role = $this->kirby()->user()?->role()->id() ?? 'nobody'; + $role = $this->kirby()->role()?->id() ?? '__none__'; return $accessible[$role] ??= $this->permissions()->can('access'); } diff --git a/src/Cms/User.php b/src/Cms/User.php index 673c45b385..a484d02ced 100644 --- a/src/Cms/User.php +++ b/src/Cms/User.php @@ -287,7 +287,7 @@ public function is(User|null $user = null): bool public function isAccessible(): bool { static $accessible = []; - $role = $this->role()->id(); + $role = $this->kirby()->role()?->id() ?? '__none__'; return $accessible[$role] ??= $this->permissions()->can('access'); }