From b1d41caf03fa2b2bd16f75f9d3de9ef20587658b Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Thu, 2 Apr 2020 11:30:15 -0400 Subject: [PATCH] Improve PluginManager code (#5023) --- modules/system/classes/PluginManager.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 1d6c0aa10..1322697d4 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -208,21 +208,17 @@ class PluginManager */ public function registerPlugin($plugin, $pluginId = null) { - if (!$pluginId) { - $pluginId = $this->getIdentifier($plugin); - } - - if (!$plugin) { - return; - } - /** * Verify that the provided plugin should be registered */ - if ($plugin->disabled || (self::$noInit && !$plugin->elevated)) { + if (!$plugin || $plugin->disabled || (self::$noInit && !$plugin->elevated)) { return; } + if (!$pluginId) { + $pluginId = $this->getIdentifier($plugin); + } + $pluginPath = $this->getPluginPath($plugin); $pluginNamespace = strtolower($pluginId); @@ -609,7 +605,7 @@ class PluginManager { $code = $this->getIdentifier($id); $code = $this->normalizeIdentifier($code); - if (array_key_exists($code, $this->disabledPlugins)) { + if (isset($this->disabledPlugins[$code])) { return false; } @@ -634,7 +630,7 @@ class PluginManager { $code = $this->getIdentifier($id); $code = $this->normalizeIdentifier($code); - if (!array_key_exists($code, $this->disabledPlugins)) { + if (!isset($this->disabledPlugins[$code])) { return false; }