Skip to content

Commit

Permalink
Dev: Only write config file when installation is completely done
Browse files Browse the repository at this point in the history
Conflicts:
	application/controllers/InstallerController.php
  • Loading branch information
olleharstedt committed Feb 23, 2018
1 parent c3001ca commit c8e62d8
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions application/controllers/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,8 @@ public function run($action = 'index')
*/
function _checkInstallation()
{
if (file_exists(APPPATH . 'config/config.php') && is_null(Yii::app()->request->getPost('InstallerConfigForm')))
{
if (file_exists(APPPATH.'config/config.php')) {
throw new CHttpException(500, 'Installation has been done already. Installer disabled.');
exit();
}
}

Expand Down Expand Up @@ -669,7 +667,7 @@ private function stepOptionalConfiguration()
$user = User::model()->findByPk(1);
if (empty($user)) {
throw new Exception('There is an admin user, but not with id 1');
}
}
} else {
$user = new User;

Expand Down Expand Up @@ -701,8 +699,28 @@ private function stepOptionalConfiguration()
$user->parent_id = 0;
$user->lang = $sSiteLanguage;
$user->email = $sAdminEmail;
$result = $user->save();
$user->save();

// only continue if we're error free otherwise setup is broken.
Yii::app()->session['deletedirectories'] = true;

$aData['title'] = gT("Success!");
$aData['descp'] = gT("LimeSurvey has been installed successfully.");
$aData['classesForStep'] = array('off', 'off', 'off', 'off', 'off', 'off');
$aData['progressValue'] = 100;
$aData['user'] = $sAdminUserName;
if ($sDefaultAdminPassword == $sAdminPassword) {
$aData['pwd'] = $sAdminPassword;
} else {
$aData['pwd'] = gT("The password you have chosen at the optional settings step.");
}

$this->_writeConfigFile();

$this->render('/installer/success_view', $aData);

return;

} catch (Exception $e) {
throw new Exception(sprintf('Could not add optional settings: %s.', $e));
}
Expand All @@ -720,16 +738,15 @@ private function stepOptionalConfiguration()
$aData['pwd'] = gT("The password you have chosen at the optional settings step.");
}

$this->_writeConfigFile();

$this->render('/installer/success_view', $aData);
return;
}
} else {
unset($aData['confirmation']);
}
} elseif(empty(Yii::app()->session['configFileWritten'])) {
$this->_writeConfigFile();
}

$this->render('/installer/optconfig_view', $aData);
}

Expand Down

0 comments on commit c8e62d8

Please sign in to comment.