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-07-08 07:40:25 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-07-08 07:40:25 +0400
commitc01d57bc17f0e9a07122539b9c5ee60872ff5a28 (patch)
tree177d48a72ad3b86bda7168388686b49237ceb2fb /core/Updater.php
parent4a9a872095b4ba8a5c416249b37647fdd9dc6e69 (diff)
this is a very complicated one. Problem was when updating from 2.4.0 to 2.5.0-b1 the updater wanted to update all dimensions (meaning alter all columns in log_visit, link_action and conversion) to the same column type. This was happening because the system did not know those dimensions were already installed from a previous Piwik version. There was an update script that was supposed to tell Piwik those components are actually already installed since we only moved them from core to plugins but it cannot work as it is an update as well and therefore not executed before the actual update check. I tried many solutions to overcome this issue including reverting all the columns to the initial MySql Schema but even then there are problems as some plugins like DevicesDetection are not defined in MySql Schema but in the plugin. It is especially complicated since users might update from 2.4 to a future version where the column type of one of those dimension changes and we need to make sure to actually execute an alter update if one of those dimension changes. In such a case we cannot directly mark the component as successfully recorded. The conclusion was for me it is only possible to solve this problem by listing all dimensions that were moved from core to plugins including their version at that time hard coded...
Diffstat (limited to 'core/Updater.php')
-rw-r--r--core/Updater.php67
1 files changed, 39 insertions, 28 deletions
diff --git a/core/Updater.php b/core/Updater.php
index 747163dfad..79754172d9 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -62,6 +62,30 @@ class Updater
}
/**
+ * Retrieve the current version of a recorded component
+ * @param string $name
+ * @return false|string
+ * @throws \Exception
+ */
+ private static function getCurrentRecordedComponentVersion($name)
+ {
+ try {
+ $currentVersion = Option::get(self::getNameInOptionTable($name));
+ } catch (\Exception $e) {
+ // mysql error 1146: table doesn't exist
+ if (Db::get()->isErrNo($e, '1146')) {
+ // case when the option table is not yet created (before 0.2.10)
+ $currentVersion = false;
+ } else {
+ // failed for some other reason
+ throw $e;
+ }
+ }
+
+ return $currentVersion;
+ }
+
+ /**
* Returns the flag name to use in the option table to record current schema version
* @param string $name
* @return string
@@ -155,7 +179,7 @@ class Updater
return '\\Piwik\\Updates\\' . $className;
}
- if ($this->isDimensionComponent($componentName)) {
+ if (ColumnUpdater::isDimensionComponent($componentName)) {
return '\\Piwik\\Columns\\Updater';
}
@@ -199,14 +223,6 @@ class Updater
return $warningMessages;
}
- private function isDimensionComponent($name)
- {
- return 0 === strpos($name, 'log_visit.')
- || 0 === strpos($name, 'log_conversion.')
- || 0 === strpos($name, 'log_conversion_item.')
- || 0 === strpos($name, 'log_link_visit_action.');
- }
-
/**
* Construct list of update files for the outdated components
*
@@ -223,7 +239,7 @@ class Updater
if ($name == 'core') {
$pathToUpdates = $this->pathUpdateFileCore . '*.php';
- } elseif ($this->isDimensionComponent($name)) {
+ } elseif (ColumnUpdater::isDimensionComponent($name)) {
$componentsWithUpdateFile[$name][PIWIK_INCLUDE_PATH . '/core/Columns/Updater.php'] = $newVersion;
} else {
$pathToUpdates = sprintf($this->pathUpdateFilePlugins, $name) . '*.php';
@@ -276,27 +292,22 @@ class Updater
$this->componentsToCheck = array_merge(array('core' => $coreVersions), $this->componentsToCheck);
}
+ $recordedCoreVersion = self::getCurrentRecordedComponentVersion('core');
+ if ($recordedCoreVersion === false) {
+ // This should not happen
+ $recordedCoreVersion = Version::VERSION;
+ self::recordComponentSuccessfullyUpdated('core', $recordedCoreVersion);
+ }
+
foreach ($this->componentsToCheck as $name => $version) {
- try {
- $currentVersion = Option::get(self::getNameInOptionTable($name));
- } catch (\Exception $e) {
- // mysql error 1146: table doesn't exist
- if (Db::get()->isErrNo($e, '1146')) {
- // case when the option table is not yet created (before 0.2.10)
- $currentVersion = false;
- } else {
- // failed for some other reason
- throw $e;
- }
- }
+ $currentVersion = self::getCurrentRecordedComponentVersion($name);
- if ($name === 'core' && $currentVersion === false) {
- // This should not happen
- $currentVersion = Version::VERSION;
- self::recordComponentSuccessfullyUpdated($name, $currentVersion);
- }
+ if (ColumnUpdater::isDimensionComponent($name)) {
+ if ($currentVersion === false && ColumnUpdater::wasDimensionMovedFromCoreToPlugin($name, $version)) {
+ self::recordComponentSuccessfullyUpdated($name, $version);
+ continue;
+ }
- if ($this->isDimensionComponent($name)) {
$isComponentOutdated = $currentVersion !== $version;
} else {
// note: when versionCompare == 1, the version in the DB is newer, we choose to ignore