Skip to content

Commit

Permalink
Fixed issue #9379: DB error during installation when unsufficient per…
Browse files Browse the repository at this point in the history
…missions to create tables
  • Loading branch information
c-schmitz committed Dec 5, 2014
1 parent 77e9362 commit d9d4a74
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions application/controllers/InstallerController.php
Expand Up @@ -238,6 +238,13 @@ private function stepDatabaseConfiguration()
$aData['classesForStep'] = array('off','off','off','on','off','off');
$aData['progressValue'] = 40;
$aData['model'] = $oModel = new InstallerConfigForm;
if (isset(Yii::app()->session['populateerror']))
{
$oModel->addError('dblocation',Yii::app()->session['populateerror']);
$oModel->addError('dbpwd','');
$oModel->addError('dbuser','');
unset(Yii::app()->session['populateerror']);
}

if(isset($_POST['InstallerConfigForm']))
{
Expand Down Expand Up @@ -576,12 +583,15 @@ function stepPopulateDb()
}
else
{
$sConfirmation = $clang->gT('Database was populated but there were errors:').'<p><ul>';
$sConfirmation = $clang->gT('There were errors when trying to populate the database :').'<p><ul>';
foreach ($aErrors as $sError)
{
$sConfirmation.='<li>'.htmlspecialchars($sError).'</li>';
}
$sConfirmation.='</ul>';
Yii::app()->session['populateerror']=$sConfirmation;

$this->redirect(array('installer/database'));
}

Yii::app()->session['tablesexist'] = true;
Expand Down Expand Up @@ -909,16 +919,20 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecurs
function _setup_tables($sFileName, $aDbConfig = array(), $sDatabasePrefix = '')
{
extract(empty($aDbConfig) ? self::_getDatabaseConfig() : $aDbConfig);
switch ($sDatabaseType) {
case 'mysql':
case 'mysqli':
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
break;
case 'pgsql':
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." SET bytea_output='escape';")->execute();
}
break;
try{
switch ($sDatabaseType) {
case 'mysql':
case 'mysqli':
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;")->execute();
break;
case 'pgsql':
if (version_compare($this->connection->getServerVersion(),'9','>=')) {
$this->connection->createCommand("ALTER DATABASE ". $this->connection->quoteTableName($sDatabaseName) ." SET bytea_output='escape';")->execute();
}
break;
}
} catch(Exception $e) {
return array($e->getMessage());
}

return $this->_executeSQLFile($sFileName, $sDatabasePrefix);
Expand Down

1 comment on commit d9d4a74

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, we don't have a try here. Thanks :)

Please sign in to comment.