From ce012dcdb2edc80ac78da7583da06fdcf2de6c88 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 7 Aug 2023 14:12:32 +0200 Subject: [PATCH] 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. --- library/Icinga/Application/Hook.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/library/Icinga/Application/Hook.php b/library/Icinga/Application/Hook.php index dcfd5dd84..9720c6ab6 100644 --- a/library/Icinga/Application/Hook.php +++ b/library/Icinga/Application/Hook.php @@ -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] ?? []; } /**