Skip to content

Commit

Permalink
refs #4631 do no longer reuse existing db info if they are already pr…
Browse files Browse the repository at this point in the history
…esent during installation. This was not working before and removed it again after it is not that easy and not really doable with the current installer.
  • Loading branch information
tsteur committed Feb 9, 2014
1 parent 42b4360 commit 3698d41
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions plugins/Installation/Controller.php
Expand Up @@ -174,25 +174,6 @@ function databaseSetup()

$this->skipThisStep(__FUNCTION__);

if (Config::getInstance()->existsLocalConfig()) {
try {
$database = Config::getInstance()->database;
if ($database) {
$db = Db::get();
DbHelper::checkDatabaseVersion();
$db->checkClientVersion();
}
$tmp = $this->session->skipThisStep;
$tmp[__FUNCTION__] = true;
$tmp['databaseCheck'] = true;
$tmp['tablesCreation'] = false;
$this->session->skipThisStep = $tmp;
$this->redirectToNextStep(__FUNCTION__ );
} catch (Exception $e) {
// existing database info in config is not complete or not valid, user has to reconfigure
}
}

$view = new View(
'@Installation/databaseSetup',
$this->getInstallationSteps(),
Expand Down Expand Up @@ -310,17 +291,12 @@ function tablesCreation()
if (count($tablesInstalled) > 0) {

// we have existing tables
$view->tablesInstalled = implode(', ', $tablesInstalled);
$view->tablesInstalled = implode(', ', $tablesInstalled);
$view->someTablesInstalled = true;

// remove monthly archive tables
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$baseTablesInstalled = count($tablesInstalled) - count($archiveTables);
$minimumCountPiwikTables = 12;

Access::getInstance();
Piwik::setUserHasSuperUserAccess();
if ($baseTablesInstalled >= $minimumCountPiwikTables &&
if ($this->hasEnoughTablesToReuseDb($tablesInstalled) &&
count(APISitesManager::getInstance()->getAllSitesId()) > 0 &&
count(APIUsersManager::getInstance()->getUsers()) > 0
) {
Expand Down Expand Up @@ -1125,4 +1101,17 @@ private function isFinishedInstallation()
return !$isInstallationInProgress;
}

private function hasEnoughTablesToReuseDb($tablesInstalled)
{
if (empty($tablesInstalled) || !is_array($tablesInstalled)) {
return false;
}

$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
$baseTablesInstalled = count($tablesInstalled) - count($archiveTables);
$minimumCountPiwikTables = 12;

return $baseTablesInstalled >= $minimumCountPiwikTables;
}

}

0 comments on commit 3698d41

Please sign in to comment.