diff --git a/library/Icinga/Application/Modules/Manager.php b/library/Icinga/Application/Modules/Manager.php index f3bf4e016..b6947c833 100644 --- a/library/Icinga/Application/Modules/Manager.php +++ b/library/Icinga/Application/Modules/Manager.php @@ -73,6 +73,13 @@ class Manager */ private $modulePaths = array(); + /** + * Whether we loaded all enabled modules + * + * @var bool + */ + private $loadedAllEnabledModules = false; + /** * Create a new instance of the module manager * @@ -177,12 +184,28 @@ class Manager */ public function loadEnabledModules() { - foreach ($this->listEnabledModules() as $name) { - $this->loadModule($name); + if (! $this->loadedAllEnabledModules) { + foreach ($this->listEnabledModules() as $name) { + $this->loadModule($name); + } + + $this->loadedAllEnabledModules = true; } + return $this; } + /** + * Whether we loaded all enabled modules + * + * @return bool + */ + public function loadedAllEnabledModules() + { + return $this->loadedAllEnabledModules; + } + + /** * Try to load the module and register it in the application * @@ -245,6 +268,8 @@ class Manager ); } + $this->loadedAllEnabledModules = false; + if (file_exists($link) && is_link($link)) { return $this; }