From 4097bffa6f71854ca942775a61e6ee478e83b141 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 1760f6e7e9..dba5fb44df 100644 --- a/src/Cms/Language.php +++ b/src/Cms/Language.php @@ -306,7 +306,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'); }