Skip to content

Commit

Permalink
Consistently cache accessibility by current role
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Dec 17, 2024
1 parent 99a7335 commit c1eca90
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Cms/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cms/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit c1eca90

Please sign in to comment.