Skip to content

NOW MANAGED ON CODEBERG

Added caching to the loading of system roles

Dan Brown8abb41abbd58
diff --git a/app/Auth/Role.php b/app/Auth/Role.php
index d6c4a0951..8f9702fa0 100644
--- a/app/Auth/Role.php
+++ b/app/Auth/Role.php
@@ -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];
}
/**