mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-10 05:06:56 +08:00
Added caching to the loading of system roles
Admin system role was being loaded for each permission check performed. This caches the fetching for the request lifetime.
This commit is contained in:
@ -111,7 +111,13 @@ class Role extends Model implements Loggable
|
||||
*/
|
||||
public static function getSystemRole(string $systemName): ?self
|
||||
{
|
||||
return static::query()->where('system_name', '=', $systemName)->first();
|
||||
static $cache = [];
|
||||
|
||||
if (!isset($cache[$systemName])) {
|
||||
$cache[$systemName] = static::query()->where('system_name', '=', $systemName)->first();
|
||||
}
|
||||
|
||||
return $cache[$systemName];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user