Run a module's configuration script only in case it has been registered

fixes #8601
This commit is contained in:
Johannes Meyer 2015-03-06 13:25:04 +01:00
parent d7dcbb48a2
commit f45f00b022
2 changed files with 34 additions and 10 deletions

View File

@ -135,22 +135,23 @@ class ConfigController extends ActionController
public function moduleAction()
{
$name = $this->getParam('name');
$app = Icinga::app();
$manager = $app->getModuleManager();
$name = $this->getParam('name');
if ($manager->hasInstalled($name)) {
$this->view->moduleData = Icinga::app()
->getModuleManager()
->select()
->from('modules')
->where('name', $name)
->fetchRow();
$module = new Module($app, $name, $manager->getModuleDir($name));
$this->view->moduleData = $manager->select()->from('modules')->where('name', $name)->fetchRow();
if ($manager->hasLoaded($name)) {
$module = $manager->getModule($name);
} else {
$module = new Module($app, $name, $manager->getModuleDir($name));
}
$this->view->module = $module;
$this->view->tabs = $module->getConfigTabs()->activate('info');
} else {
$this->view->module = false;
$this->view->tabs = null;
}
$this->view->tabs = $module->getConfigTabs()->activate('info');
}
/**

View File

@ -113,6 +113,13 @@ class Module
*/
private $triedToLaunchConfigScript = false;
/**
* Whether this module has been registered
*
* @var bool
*/
private $registered = false;
/**
* Provided permissions
*
@ -279,6 +286,10 @@ class Module
*/
public function register()
{
if ($this->registered) {
return true;
}
$this->registerAutoloader();
try {
$this->launchRunScript();
@ -291,10 +302,22 @@ class Module
);
return false;
}
$this->registerWebIntegration();
$this->registered = true;
return true;
}
/**
* Return whether this module has been registered
*
* @return bool
*/
public function isRegistered()
{
return $this->registered;
}
/**
* Test for an enabled module by name
*
@ -913,7 +936,7 @@ class Module
*/
protected function launchConfigScript()
{
if ($this->triedToLaunchConfigScript) {
if ($this->triedToLaunchConfigScript || !$this->registered) {
return;
}
$this->triedToLaunchConfigScript = true;