diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-04-14 04:57:52 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-04-16 07:39:18 +0300 |
commit | 6b6743c0da73087e2d5534889201355bad500c3e (patch) | |
tree | 4b8ce39ccac582a0d5f9bca3f46c92dacbabb1e8 /core/Plugin | |
parent | 140c3b03e79499835a9af406e591b26869beba28 (diff) |
Improve performance of BulkTracking and QueuedTracking
Diffstat (limited to 'core/Plugin')
-rw-r--r-- | core/Plugin/Manager.php | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 22eb0296d1..6249cf71dd 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -44,6 +44,8 @@ class Manager extends Singleton protected $doLoadPlugins = true; + private $pluginsLoadedAndActivated; + /** * @var Plugin[] */ @@ -426,6 +428,7 @@ class Manager extends Singleton */ private function clearCache($pluginName) { + $this->resetTransientCache(); Filesystem::deleteAllCacheOnUpdate($pluginName); } @@ -678,6 +681,7 @@ class Manager extends Singleton */ public function loadPlugins(array $pluginsToLoad) { + $this->resetTransientCache(); $this->pluginsToLoad = $this->makePluginsToLoad($pluginsToLoad); $this->reloadActivatedPlugins(); } @@ -765,15 +769,21 @@ class Manager extends Singleton */ public function getPluginsLoadedAndActivated() { - $plugins = $this->getLoadedPlugins(); - $enabled = $this->getActivatedPlugins(); + if (is_null($this->pluginsLoadedAndActivated)) { + $enabled = $this->getActivatedPlugins(); - if (empty($enabled)) { - return array(); + if (empty($enabled)) { + return array(); + } + + $plugins = $this->getLoadedPlugins(); + $enabled = array_combine($enabled, $enabled); + $plugins = array_intersect_key($plugins, $enabled); + + $this->pluginsLoadedAndActivated = $plugins; } - $enabled = array_combine($enabled, $enabled); - $plugins = array_intersect_key($plugins, $enabled); - return $plugins; + + return $this->pluginsLoadedAndActivated; } /** @@ -936,6 +946,11 @@ class Manager extends Singleton return "\\Piwik\\Plugins\\$pluginName\\$className"; } + private function resetTransientCache() + { + $this->pluginsLoadedAndActivated = null; + } + /** * Unload plugin * @@ -944,6 +959,8 @@ class Manager extends Singleton */ public function unloadPlugin($plugin) { + $this->resetTransientCache(); + if (!($plugin instanceof Plugin)) { $oPlugin = $this->loadPlugin($plugin); if ($oPlugin === null) { @@ -962,6 +979,8 @@ class Manager extends Singleton */ public function unloadPlugins() { + $this->resetTransientCache(); + $pluginsLoaded = $this->getLoadedPlugins(); foreach ($pluginsLoaded as $plugin) { $this->unloadPlugin($plugin); @@ -992,6 +1011,8 @@ class Manager extends Singleton */ public function addLoadedPlugin($pluginName, Plugin $newPlugin) { + $this->resetTransientCache(); + $this->loadedPlugins[$pluginName] = $newPlugin; } |