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
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2019-07-12 00:40:51 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-07-12 00:40:51 +0300
commitce9b7cb69e349489e74527749c47e080fed27128 (patch)
tree35e4a3266e4632c6961301eba0e2901ea5307f52 /plugins/CustomVariables
parent927c9379b7c717da88cca3fc158f4e814731c598 (diff)
various performance tweaks (#14624)
* various performance tweaks * tweak so tests dont fail * Update Manager.php * Update Plugin.php * cache custom variables properly
Diffstat (limited to 'plugins/CustomVariables')
-rw-r--r--plugins/CustomVariables/CustomVariables.php39
1 files changed, 22 insertions, 17 deletions
diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php
index 90ea2672ad..2437941f8a 100644
--- a/plugins/CustomVariables/CustomVariables.php
+++ b/plugins/CustomVariables/CustomVariables.php
@@ -24,7 +24,8 @@ class CustomVariables extends \Piwik\Plugin
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'Dimension.addDimensions' => 'addDimensions',
- 'Actions.getCustomActionDimensionFieldsAndJoins' => 'provideActionDimensionFields'
+ 'Actions.getCustomActionDimensionFieldsAndJoins' => 'provideActionDimensionFields',
+ 'Tracker.setTrackerCacheGeneral' => 'getCacheGeneral'
);
}
@@ -78,32 +79,36 @@ class CustomVariables extends \Piwik\Plugin
$cache = Cache::getCacheGeneral();
$cacheKey = self::MAX_NUM_CUSTOMVARS_CACHEKEY;
- if (!array_key_exists($cacheKey, $cache)) {
+ return $cache[$cacheKey];
+ }
- $minCustomVar = null;
+ public function getCacheGeneral(&$cacheContent)
+ {
+ $cacheContent[self::MAX_NUM_CUSTOMVARS_CACHEKEY] = self::fetchNumMaxCustomVariables();
+ }
- foreach (Model::getScopes() as $scope) {
- $model = new Model($scope);
- $highestIndex = $model->getHighestCustomVarIndex();
+ private static function fetchNumMaxCustomVariables()
+ {
+ $minCustomVar = null;
- if (!isset($minCustomVar)) {
- $minCustomVar = $highestIndex;
- }
+ foreach (Model::getScopes() as $scope) {
+ $model = new Model($scope);
+ $highestIndex = $model->getHighestCustomVarIndex();
- if ($highestIndex < $minCustomVar) {
- $minCustomVar = $highestIndex;
- }
+ if (!isset($minCustomVar)) {
+ $minCustomVar = $highestIndex;
}
- if (!isset($minCustomVar)) {
- $minCustomVar = 0;
+ if ($highestIndex < $minCustomVar) {
+ $minCustomVar = $highestIndex;
}
+ }
- $cache[$cacheKey] = $minCustomVar;
- Cache::setCacheGeneral($cache);
+ if (!isset($minCustomVar)) {
+ $minCustomVar = 0;
}
- return $cache[$cacheKey];
+ return $minCustomVar;
}
public function getClientSideTranslationKeys(&$translationKeys)