Skip to content

Commit

Permalink
Fixes #5115 Fixes couple issues in the logic which should finally sol…
Browse files Browse the repository at this point in the history
…ve reported issues.
  • Loading branch information
mattab committed May 9, 2014
1 parent aa810b6 commit f27c691
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 2 additions & 0 deletions core/Plugin/Manager.php
Expand Up @@ -235,6 +235,8 @@ private function updatePluginsInstalledConfig($plugins)
public function clearPluginsInstalledConfig()
{
$this->updatePluginsInstalledConfig( array() );
PiwikConfig::getInstance()->forceSave();
PiwikConfig::getInstance()->init();
}

/**
Expand Down
21 changes: 8 additions & 13 deletions core/Updater.php
Expand Up @@ -252,26 +252,21 @@ public function getComponentsWithNewVersion()
throw $e;
}
}
if ($currentVersion === false) {
if ($name === 'core') {
// This should not happen
$currentVersion = Version::VERSION;
} else {
// When plugins have been installed since Piwik 2.0 this should not happen
// We "fix" the data for any plugin that may have been ported from Piwik 1.x
$currentVersion = $version;
}

if ($name === 'core' && $currentVersion === false) {
// This should not happen
$currentVersion = Version::VERSION;
self::recordComponentSuccessfullyUpdated($name, $currentVersion);
}

$versionCompare = version_compare($currentVersion, $version);
if ($versionCompare == -1) {
// note: when versionCompare == 1, the version in the DB is newer, we choose to ignore
$currentVersionIsOutdated = version_compare($currentVersion, $version) == -1;
$isComponentOutdated = $currentVersion === false || $currentVersionIsOutdated;
if ($isComponentOutdated) {
$componentsToUpdate[$name] = array(
self::INDEX_CURRENT_VERSION => $currentVersion,
self::INDEX_NEW_VERSION => $version
);
} else if ($versionCompare == 1) {
// the version in the DB is newest.. we choose to ignore
}
}
return $componentsToUpdate;
Expand Down
10 changes: 7 additions & 3 deletions plugins/CoreUpdater/CoreUpdater.php
Expand Up @@ -111,13 +111,17 @@ public static function updateComponents(Updater $updater, $componentsWithUpdateF
public static function getComponentUpdates(Updater $updater)
{
$updater->addComponentToCheck('core', Version::VERSION);
$plugins = \Piwik\Plugin\Manager::getInstance()->getLoadedPlugins();
$manager = \Piwik\Plugin\Manager::getInstance();
$plugins = $manager->getLoadedPlugins();
foreach ($plugins as $pluginName => $plugin) {
$updater->addComponentToCheck($pluginName, $plugin->getVersion());
if($manager->isPluginInstalled($pluginName)) {
$updater->addComponentToCheck($pluginName, $plugin->getVersion());
}
}

$componentsWithUpdateFile = $updater->getComponentsWithUpdateFile();
if (count($componentsWithUpdateFile) == 0 && !$updater->hasNewVersion('core')) {
if (count($componentsWithUpdateFile) == 0
&& !$updater->hasNewVersion('core')) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/Installation/Controller.php
Expand Up @@ -182,6 +182,7 @@ function tablesCreation()
);

if ($this->getParam('deleteTables')) {
Manager::getInstance()->clearPluginsInstalledConfig();
Db::dropAllTables();
$view->existingTablesDeleted = true;
}
Expand All @@ -205,7 +206,6 @@ function tablesCreation()
}
} else {

Manager::getInstance()->clearPluginsInstalledConfig();
DbHelper::createTables();
DbHelper::createAnonymousUser();

Expand Down

0 comments on commit f27c691

Please sign in to comment.