Skip to content

Commit

Permalink
Refs #5005 Delete the config file when it is found, during installati…
Browse files Browse the repository at this point in the history
…on, to prevent unexpected bugs
  • Loading branch information
mattab committed May 2, 2014
1 parent c913ce3 commit 7192213
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
6 changes: 6 additions & 0 deletions core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ public function existsLocalConfig()
return is_readable($this->pathLocal);
}

public function deleteLocalConfig()
{
$configLocal = $this->getLocalPath();
unlink($configLocal);
}

public function checkLocalConfigFound()
{
if (!$this->existsLocalConfig()) {
Expand Down
33 changes: 14 additions & 19 deletions plugins/Installation/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Piwik\Plugins\UsersManager\API as APIUsersManager;
use Piwik\ProxyHeaders;
use Piwik\Session\SessionNamespace;
use Piwik\SettingsPiwik;
use Piwik\SettingsServer;
use Piwik\Updater;
use Piwik\UpdaterErrorException;
Expand Down Expand Up @@ -192,7 +193,8 @@ function databaseSetup()
DbHelper::checkDatabaseVersion();
$this->session->databaseVersionOk = true;

$this->createConfigFileIfNeeded($dbInfos);
$this->deleteConfigFileIfNeeded();
$this->createConfigFile($dbInfos);

$this->redirectToNextStep(__FUNCTION__);
} catch (Exception $e) {
Expand Down Expand Up @@ -278,7 +280,6 @@ function tablesCreation()
$view->existingTablesDeleted = true;

// when the user decides to drop the tables then we dont skip the next steps anymore
// workaround ZF-1743
$tmp = $this->session->skipThisStep;
$tmp['firstWebsiteSetup'] = false;
$tmp['trackingCode'] = false;
Expand All @@ -302,7 +303,6 @@ function tablesCreation()
) {
$view->showReuseExistingTables = true;
// when the user reuses the same tables we skip the website creation step
// workaround ZF-1743
$tmp = $this->session->skipThisStep;
$tmp['firstWebsiteSetup'] = true;
$tmp['trackingCode'] = true;
Expand Down Expand Up @@ -569,21 +569,11 @@ protected function initObjectsToCallAPI()
/**
* Write configuration file from session-store
*/
protected function createConfigFileIfNeeded($dbInfos)
protected function createConfigFile($dbInfos)
{
$config = Config::getInstance();

try {
// expect exception since config.ini.php doesn't exist yet
$config->checkLocalConfigFound();

} catch (Exception $e) {

if (!empty($this->session->general_infos)) {
$config->General = $this->session->general_infos;
}
}

$config->General = $this->session->general_infos;
$config->General['installation_in_progress'] = 1;
$config->database = $dbInfos;
$config->forceSave();
Expand Down Expand Up @@ -920,7 +910,6 @@ public static function getSystemInformation()
return $infos;
}


/**
* @param $infos
* @return mixed
Expand Down Expand Up @@ -1090,9 +1079,7 @@ private function createSuperUser($login, $password, $email)

private function isFinishedInstallation()
{
$isConfigFileFound = file_exists(Config::getInstance()->getLocalPath());

if (!$isConfigFileFound) {
if (!SettingsPiwik::isPiwikInstalled()) {
return false;
}

Expand All @@ -1119,4 +1106,12 @@ private function hasEnoughTablesToReuseDb($tablesInstalled)
return $baseTablesInstalled >= $minimumCountPiwikTables;
}

protected function deleteConfigFileIfNeeded()
{
$config = Config::getInstance();
if($config->existsLocalConfig()) {
$config->deleteLocalConfig();
}
}

}

0 comments on commit 7192213

Please sign in to comment.