diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-03 06:24:11 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-03 06:24:11 +0400 |
commit | 26043d38220da7cb0bebe1aed40ce472647f30d4 (patch) | |
tree | 0f76e908a92ba661abd361f2678bf2cacaa58a13 /plugins/CustomVariables/Model.php | |
parent | 625a29757d5d94194fb152508752123db8feb0de (diff) |
moving getMaxCustomVariables to CustomVariables class, a model should not really care about caching etc
Diffstat (limited to 'plugins/CustomVariables/Model.php')
-rw-r--r-- | plugins/CustomVariables/Model.php | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/plugins/CustomVariables/Model.php b/plugins/CustomVariables/Model.php index d33fe3353c..252718f87a 100644 --- a/plugins/CustomVariables/Model.php +++ b/plugins/CustomVariables/Model.php @@ -12,7 +12,6 @@ use Piwik\Common; use Piwik\DataTable; use Piwik\Db; use Piwik\Log; -use Piwik\Tracker\Cache; class Model { @@ -92,8 +91,6 @@ 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; } @@ -101,11 +98,10 @@ class Model { $dbTable = Common::prefixTable($this->scope); $index = $this->getHighestCustomVarIndex() + 1; + $maxLen = CustomVariables::getMaxLengthCustomVariables(); - 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(); + Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, $maxLen)); + Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, $maxLen)); return $index; } @@ -124,40 +120,6 @@ class Model return array(self::SCOPE_PAGE, self::SCOPE_VISIT, self::SCOPE_CONVERSION); } - public static function getMaxCustomVariables() - { - $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]; - } - - /** - * There are also some hardcoded places in JavaScript - * @return int - */ - public static function getMaxLengthCustomVariables() - { - return 200; - } - public static function install() { foreach (self::getScopes() as $scope) { |