Hook: Don't abort loading remaining hooks due to one broken hook

`Hook::all()` shouldn't abort loading the remaining hooks when one of
the provided hook is broken.
This commit is contained in:
Yonas Habteab 2023-08-07 14:12:32 +02:00 committed by Johannes Meyer
parent dec24686bc
commit ce012dcdb2
1 changed files with 4 additions and 6 deletions

View File

@ -266,23 +266,21 @@ class Hook
*
* @return array
*/
public static function all($name)
public static function all($name): array
{
$name = self::normalizeHookName($name);
if (! self::has($name)) {
return array();
return [];
}
foreach (self::$hooks[$name] as $key => $hook) {
list($class, $alwaysRun) = $hook;
if ($alwaysRun || self::hasPermission($class)) {
if (self::createInstance($name, $key) === null) {
return array();
}
self::createInstance($name, $key);
}
}
return isset(self::$instances[$name]) ? self::$instances[$name] : array();
return self::$instances[$name] ?? [];
}
/**