Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2017-09-07 04:40:46 +0300
committerGitHub <noreply@github.com>2017-09-07 04:40:46 +0300
commit97941db8c8ea36dd36551360ea8ee4d127d595d6 (patch)
treee3d62a8251700e97583150d424557528850b4b95 /core
parent5d90f2e01d9a5ef298300b478d367c14b2adebc5 (diff)
Restore the speed of Visitor Log (#12009)
* render template only if needed * reuse same Twig instance * cache CacheBuster to prevent recalculation when needed multiple times
Diffstat (limited to 'core')
-rw-r--r--core/AssetManager/UIAssetCacheBuster.php32
-rw-r--r--core/View.php9
2 files changed, 29 insertions, 12 deletions
diff --git a/core/AssetManager/UIAssetCacheBuster.php b/core/AssetManager/UIAssetCacheBuster.php
index fcbd0720a9..15b55943b9 100644
--- a/core/AssetManager/UIAssetCacheBuster.php
+++ b/core/AssetManager/UIAssetCacheBuster.php
@@ -27,20 +27,32 @@ class UIAssetCacheBuster extends Singleton
*/
public function piwikVersionBasedCacheBuster($pluginNames = false)
{
- $masterFile = PIWIK_INCLUDE_PATH . '/.git/refs/heads/master';
- $currentGitHash = file_exists($masterFile) ? @file_get_contents($masterFile) : null;
+ static $cachedCacheBuster = null;
- $pluginNames = !$pluginNames ? Manager::getInstance()->getLoadedPluginsName() : $pluginNames;
- sort($pluginNames);
+ if (empty($cachedCacheBuster) || $pluginNames !== false) {
- $pluginsInfo = '';
- foreach ($pluginNames as $pluginName) {
- $plugin = Manager::getInstance()->getLoadedPlugin($pluginName);
- $pluginsInfo .= $plugin->getPluginName() . $plugin->getVersion() . ',';
+ $masterFile = PIWIK_INCLUDE_PATH . '/.git/refs/heads/master';
+ $currentGitHash = file_exists($masterFile) ? @file_get_contents($masterFile) : null;
+
+ $plugins = !$pluginNames ? Manager::getInstance()->getLoadedPluginsName() : $pluginNames;
+ sort($plugins);
+
+ $pluginsInfo = '';
+ foreach ($plugins as $pluginName) {
+ $plugin = Manager::getInstance()->getLoadedPlugin($pluginName);
+ $pluginsInfo .= $plugin->getPluginName() . $plugin->getVersion() . ',';
+ }
+
+ $cacheBuster = md5($pluginsInfo . PHP_VERSION . Version::VERSION . trim($currentGitHash));
+
+ if ($pluginNames !== false) {
+ return $cacheBuster;
+ }
+
+ $cachedCacheBuster = $cacheBuster;
}
- $cacheBuster = md5($pluginsInfo . PHP_VERSION . Version::VERSION . trim($currentGitHash));
- return $cacheBuster;
+ return $cachedCacheBuster;
}
/**
diff --git a/core/View.php b/core/View.php
index e74eae6201..3c90b5f9a7 100644
--- a/core/View.php
+++ b/core/View.php
@@ -212,10 +212,15 @@ class View implements ViewInterface
return isset($this->templateVars[$name]);
}
+ /** @var Twig */
+ static $twigCached = null;
+
private function initializeTwig()
{
- $piwikTwig = new Twig();
- $this->twig = $piwikTwig->getTwigEnvironment();
+ if (empty(static::$twigCached)) {
+ static::$twigCached = new Twig();
+ }
+ $this->twig = static::$twigCached->getTwigEnvironment();
}
/**