Commit 5042df42 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski

Revert plugin autoinit from commit 5b9affbc; fixes #5637

parent 0e7d0f7d
......@@ -383,6 +383,8 @@ class Application extends BaseApplication {
}
$plugin = new Plugin();
$plugin->init();
$plugins_list = $plugin->getPlugins();
if (count($plugins_list) > 0) {
foreach ($plugins_list as $name) {
......
......@@ -96,6 +96,7 @@ if (!isset($PLUGINS_INCLUDED)) {
$PLUGINS_INCLUDED = 1;
$LOADED_PLUGINS = [];
$plugin = new Plugin();
$plugin->init();
$plugins_list = $plugin->getPlugins();
if (count($plugins_list)) {
......
......@@ -98,18 +98,23 @@ class Plugin extends CommonDBTM {
function init() {
global $DB, $GLPI_CACHE;
$GLPI_CACHE->set('plugins', []);
if (!isset($DB) || !$DB->connected) {
// Cannot init plugins list if DB is not connected
$GLPI_CACHE->set('plugins_init', true);
$GLPI_CACHE->set('plugins', []);
return;
}
$this->checkStates();
$plugins = $this->find(['state' => self::ACTIVATED]);
foreach ($plugins as $ID => $plug) {
$this->setLoaded($ID, $plug['directory']);
$GLPI_CACHE->set('plugins_init', true);
$GLPI_CACHE->set('plugins', []);
if (count($plugins)) {
foreach ($plugins as $ID => $plug) {
$this->setLoaded($ID, $plug['directory']);
}
}
}
......@@ -125,8 +130,7 @@ class Plugin extends CommonDBTM {
Toolbox::deprecated();
global $GLPI_CACHE;
return $GLPI_CACHE->has('plugins');
return $GLPI_CACHE->has('plugins_init');
}
......@@ -715,8 +719,9 @@ class Plugin extends CommonDBTM {
**/
function isActivated($plugin) {
$activePlugins = $this->getPlugins();
return in_array($plugin, $activePlugins);
if ($this->getFromDBbyDir($plugin)) {
return ($this->fields['state'] == self::ACTIVATED);
}
}
......@@ -727,11 +732,6 @@ class Plugin extends CommonDBTM {
**/
function isInstalled($plugin) {
if ($this->isActivated($plugin)) {
// Prevent call on DB if plugin is activated.
return true;
}
if ($this->getFromDBbyDir($plugin)) {
return (($this->fields['state'] == self::ACTIVATED)
|| ($this->fields['state'] == self::TOBECONFIGURED)
......@@ -1707,13 +1707,10 @@ class Plugin extends CommonDBTM {
*/
public static function getPlugins() {
global $GLPI_CACHE;
if (!$GLPI_CACHE->has('plugins')) {
$self = new self();
$self->init();
if ($GLPI_CACHE && $GLPI_CACHE->has('plugins')) {
return $GLPI_CACHE->get('plugins');
}
return $GLPI_CACHE->get('plugins');
return [];
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment