diff --git a/Sources/Permissions/GroupPermissionSet.php b/Sources/Permissions/GroupPermissionSet.php index 17126719b7..462eeaa9a6 100644 --- a/Sources/Permissions/GroupPermissionSet.php +++ b/Sources/Permissions/GroupPermissionSet.php @@ -284,8 +284,9 @@ public static function load(array|int $profiles, array|int $groups, bool $refres // to query the database separately below. self::$query_during_construction = false; - // Initialize the objects. - $loaded[] = new self($profile, $group); + // Initialize the objects. The constructor registers each one in + // self::$loaded, which is where they are collected from below. + new self($profile, $group); // Restore this to its normal value. self::$query_during_construction = true; @@ -300,6 +301,17 @@ public static function load(array|int $profiles, array|int $groups, bool $refres // Board permissions. self::loadBoardPermissionData($profiles, $query_groups); + + // A set that came from the cache takes the place of the instance the + // constructor registered, so the ones to hand back are whichever + // ended up in self::$loaded. + foreach ($profiles as $profile) { + foreach ($query_groups as $group) { + if (isset(self::$loaded[$profile][$group])) { + $loaded[] = self::$loaded[$profile][$group]; + } + } + } } return $loaded; @@ -421,7 +433,7 @@ protected static function loadBoardPermissionData(array $profiles, array $groups } } - if ($hits = \count($profiles)) { + if ($hits === \count($profiles)) { unset($groups[$g]); } }