diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-07-03 02:50:30 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-07-03 02:50:30 +0400 |
commit | 72ca100dfeddad8e90177ee6cdc5dfb684863011 (patch) | |
tree | d5053d6cb7327d1a81bf787c494173c4e699171b /core/Plugin.php | |
parent | b5ac22280e0538b4753c8331ff4dae11c055ed0e (diff) |
performance improvement by not having to use the autoloader when loading a single component
Diffstat (limited to 'core/Plugin.php')
-rw-r--r-- | core/Plugin.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/Plugin.php b/core/Plugin.php index 8754804958..241773aded 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -307,6 +307,8 @@ class Plugin { $this->cache->setCacheKey('Plugin' . $this->pluginName . $componentName . $expectedSubclass); + $componentFile = sprintf('%s/plugins/%s/%s.php', PIWIK_INCLUDE_PATH, $this->pluginName, $componentName); + if ($this->cache->has()) { $klassName = $this->cache->get(); @@ -314,11 +316,11 @@ class Plugin return; // might by "false" in case has no menu, widget, ... } + include_once $componentFile; + } else { $this->cache->set(false); // prevent from trying to load over and over again for instance if there is no Menu for a plugin - $componentFile = sprintf('%s/plugins/%s/%s.php', PIWIK_INCLUDE_PATH, $this->pluginName, $componentName); - if (!file_exists($componentFile)) { return; } @@ -337,7 +339,7 @@ class Plugin return; } - $this->cache->set($klassName); + $this->cache->set(array($klassName)); } return new $klassName; @@ -351,7 +353,7 @@ class Plugin $components = $this->cache->get(); foreach ($components as $file => $klass) { - require_once $file; + include_once $file; } return $components; |