diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-07-11 07:39:50 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-07-11 07:39:50 +0400 |
commit | 2a9144c632f775d25c4faa3cb0b82391c013891a (patch) | |
tree | 6f8396862788932991242ced551a63161a6e7b31 /core/Columns | |
parent | 6ae5b6c6058768ce34a90f9bbffbc0d9e99b3d3f (diff) |
just noticed I broke the installer when I was trying to fix the updater in c01d57bc17, this might work... basically the idea was ok but we should check for this only if the column actually already exists. If the column does not exist yet we need to make sure it will be installed
Diffstat (limited to 'core/Columns')
-rw-r--r-- | core/Columns/Updater.php | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/core/Columns/Updater.php b/core/Columns/Updater.php index c04779a81c..d092cd308a 100644 --- a/core/Columns/Updater.php +++ b/core/Columns/Updater.php @@ -163,27 +163,52 @@ class Updater extends \Piwik\Updates $versions = array(); + $visitColumns = DbHelper::getTableColumns(Common::prefixTable('log_visit')); + $actionColumns = DbHelper::getTableColumns(Common::prefixTable('log_link_visit_action')); + $conversionColumns = DbHelper::getTableColumns(Common::prefixTable('log_conversion')); + foreach (VisitDimension::getAllDimensions() as $dimension) { - $columnName = $dimension->getColumnName(); - if ($columnName && $dimension->hasColumnType()) { - $versions['log_visit.' . $columnName] = $dimension->getVersion(); - } + $versions = self::mixinVersions($dimension, 'log_visit.', $visitColumns, $versions); } foreach (ActionDimension::getAllDimensions() as $dimension) { - $columnName = $dimension->getColumnName(); - if ($columnName && $dimension->hasColumnType()) { - $versions['log_link_visit_action.' . $columnName] = $dimension->getVersion(); - } + $versions = self::mixinVersions($dimension, 'log_link_visit_action.', $actionColumns, $versions); } foreach (ConversionDimension::getAllDimensions() as $dimension) { - $columnName = $dimension->getColumnName(); - if ($columnName && $dimension->hasColumnType()) { - $versions['log_conversion.' . $columnName] = $dimension->getVersion(); - } + $versions = self::mixinVersions($dimension, 'log_conversion.', $conversionColumns, $versions); + } + + return $versions; + } + + /** + * @param ActionDimension|ConversionDimension|VisitDimension $dimension + * @param string $componentPrefix + * @param array $columns + * @param array $versions + * @return array The modified versions array + */ + private static function mixinVersions($dimension, $componentPrefix, $columns, $versions) + { + $columnName = $dimension->getColumnName(); + + if (!$columnName || !$dimension->hasColumnType()) { + return $versions; } + $component = $componentPrefix . $columnName; + $version = $dimension->getVersion(); + + if (in_array($columnName, $columns) + && false === PiwikUpdater::getCurrentRecordedComponentVersion($component) + && self::wasDimensionMovedFromCoreToPlugin($component, $version)) { + PiwikUpdater::recordComponentSuccessfullyUpdated($component, $version); + return $versions; + } + + $versions[$component] = $version; + return $versions; } |