mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 17:24:16 +02:00
Run a module's configuration script only in case it has been registered
fixes #8601
This commit is contained in:
parent
d7dcbb48a2
commit
f45f00b022
@ -135,22 +135,23 @@ class ConfigController extends ActionController
|
|||||||
|
|
||||||
public function moduleAction()
|
public function moduleAction()
|
||||||
{
|
{
|
||||||
$name = $this->getParam('name');
|
|
||||||
$app = Icinga::app();
|
$app = Icinga::app();
|
||||||
$manager = $app->getModuleManager();
|
$manager = $app->getModuleManager();
|
||||||
|
$name = $this->getParam('name');
|
||||||
if ($manager->hasInstalled($name)) {
|
if ($manager->hasInstalled($name)) {
|
||||||
$this->view->moduleData = Icinga::app()
|
$this->view->moduleData = $manager->select()->from('modules')->where('name', $name)->fetchRow();
|
||||||
->getModuleManager()
|
if ($manager->hasLoaded($name)) {
|
||||||
->select()
|
$module = $manager->getModule($name);
|
||||||
->from('modules')
|
} else {
|
||||||
->where('name', $name)
|
|
||||||
->fetchRow();
|
|
||||||
$module = new Module($app, $name, $manager->getModuleDir($name));
|
$module = new Module($app, $name, $manager->getModuleDir($name));
|
||||||
|
}
|
||||||
|
|
||||||
$this->view->module = $module;
|
$this->view->module = $module;
|
||||||
|
$this->view->tabs = $module->getConfigTabs()->activate('info');
|
||||||
} else {
|
} else {
|
||||||
$this->view->module = false;
|
$this->view->module = false;
|
||||||
|
$this->view->tabs = null;
|
||||||
}
|
}
|
||||||
$this->view->tabs = $module->getConfigTabs()->activate('info');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,6 +113,13 @@ class Module
|
|||||||
*/
|
*/
|
||||||
private $triedToLaunchConfigScript = false;
|
private $triedToLaunchConfigScript = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this module has been registered
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $registered = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provided permissions
|
* Provided permissions
|
||||||
*
|
*
|
||||||
@ -279,6 +286,10 @@ class Module
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
if ($this->registered) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerAutoloader();
|
$this->registerAutoloader();
|
||||||
try {
|
try {
|
||||||
$this->launchRunScript();
|
$this->launchRunScript();
|
||||||
@ -291,10 +302,22 @@ class Module
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerWebIntegration();
|
$this->registerWebIntegration();
|
||||||
|
$this->registered = true;
|
||||||
return 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
|
* Test for an enabled module by name
|
||||||
*
|
*
|
||||||
@ -913,7 +936,7 @@ class Module
|
|||||||
*/
|
*/
|
||||||
protected function launchConfigScript()
|
protected function launchConfigScript()
|
||||||
{
|
{
|
||||||
if ($this->triedToLaunchConfigScript) {
|
if ($this->triedToLaunchConfigScript || !$this->registered) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->triedToLaunchConfigScript = true;
|
$this->triedToLaunchConfigScript = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user