Skip to content

Commit

Permalink
Fixed issue: Console installation from config file not working
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Feb 7, 2018
1 parent 622bebd commit 0d50c82
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions application/commands/InstallFromConfigCommand.php
Expand Up @@ -42,7 +42,7 @@ public function run($aArguments)
{

if (isset($aArguments) && isset($aArguments[0])) {
$readFromConfig = realpath(dirname(APPPATH).DIRECTORY_SEPARATOR.$aArguments[0]);
$readFromConfig = realpath($aArguments[0]);
$this->configuration = include($readFromConfig);
$this->dbConnectionArray = $this->configuration['components']['db'];

Expand All @@ -57,9 +57,10 @@ public function run($aArguments)
try {
$this->output('Connecting to database...');
$this->connection = App()->getDb();
$this->connection->connectionString = $dbConnectArray['connectionString'];
$this->connection->username = $dbConnectArray['username'];
$this->connection->password = $dbConnectArray['password']; $this->connection->active = true;
$this->connection->connectionString = $this->dbConnectionArray['connectionString'];
$this->connection->username = $this->dbConnectionArray['username'];
$this->connection->password = $this->dbConnectionArray['password'];
$this->connection->active = true;
$this->output('Using connection string '.$this->connection->connectionString);
} catch (CDbException $e) {
$this->output('Could not connect to database: '.$e->getMessage());
Expand Down Expand Up @@ -96,12 +97,12 @@ public function run($aArguments)
$this->connection->createCommand()->insert(
$this->connection->tablePrefix.'users',
array(
'users_name'=>$this->configuration['defaultuser'],
'password'=>password_hash($this->configuration['defaultpass'], PASSWORD_DEFAULT),

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Jul 24, 2019

Collaborator

password need to be hashed to work , see https://bugs.limesurvey.org/view.php?id=15069#c52985

'users_name'=>$this->configuration['config']['defaultuser'],
'password'=>$this->configuration['config']['defaultpass'],
'full_name'=>"",
'parent_id'=>0,
'lang'=>'auto',
'email'=>$this->configuration['defaultemail']
'email'=>$this->configuration['config']['siteadminemail']
)
);
$this->connection->createCommand()->insert(
Expand All @@ -123,7 +124,7 @@ public function run($aArguments)
return 0;
} else {
// TODO: a valid error process
echo "You have to set admin/password/full name and email address on the command line like this: php console.php install adminname mypassword fullname emailaddress [verbose]\n";
echo "You have to set the path to the config file as only parameter\n";
return 1;
}
}
Expand Down

0 comments on commit 0d50c82

Please sign in to comment.