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 <thomas.steur@googlemail.com>2014-04-03 06:03:54 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-04-03 06:03:54 +0400
commit625a29757d5d94194fb152508752123db8feb0de (patch)
tree9e99eed08dba567cf05b03fa62509cf225baed5e /plugins
parent26d67856959d73946e54de76116c7169b1a3dd5f (diff)
detect the number of max custom variables
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CustomVariables/Model.php27
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/CustomVariables/Model.php b/plugins/CustomVariables/Model.php
index a3cbf90d8c..d33fe3353c 100644
--- a/plugins/CustomVariables/Model.php
+++ b/plugins/CustomVariables/Model.php
@@ -12,6 +12,7 @@ use Piwik\Common;
use Piwik\DataTable;
use Piwik\Db;
use Piwik\Log;
+use Piwik\Tracker\Cache;
class Model
{
@@ -91,6 +92,8 @@ class Model
Db::exec(sprintf('ALTER TABLE %s DROP COLUMN custom_var_k%d', $dbTable, $index));
Db::exec(sprintf('ALTER TABLE %s DROP COLUMN custom_var_v%d', $dbTable, $index));
+ Cache::clearCacheGeneral();
+
return $index;
}
@@ -102,6 +105,8 @@ class Model
Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, self::getMaxLengthCustomVariables()));
Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, self::getMaxLengthCustomVariables()));
+ Cache::clearCacheGeneral();
+
return $index;
}
@@ -121,7 +126,27 @@ class Model
public static function getMaxCustomVariables()
{
- return 5;
+ $cache = Cache::getCacheGeneral();
+ $cacheKey = 'CustomVariables.MaxNumCustomVariables';
+
+ if (!array_key_exists($cacheKey, $cache)) {
+
+ $maxCustomVar = 0;
+
+ foreach (self::getScopes() as $scope) {
+ $model = new Model($scope);
+ $highestIndex = $model->getHighestCustomVarIndex();
+
+ if ($highestIndex > $maxCustomVar) {
+ $maxCustomVar = $highestIndex;
+ }
+ }
+
+ $cache[$cacheKey] = $maxCustomVar;
+ Cache::setCacheGeneral($cache);
+ }
+
+ return $cache[$cacheKey];
}
/**