Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Fix issue with database connection during installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Nov 19, 2014
1 parent 5a42749 commit 3b43a72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions core/controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ public function step2Action()
}

$db = Zend_Db::factory($dbtype, $params);
$this->Component->Utility->run_sql_from_file($db, $sqlFile);

Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('dbAdapter', $db);

$this->Component->Utility->run_sql_from_file($db, $sqlFile);

// Must generate and store our password salt before we create our first user
$options = array('allowModifications' => true);
$applicationConfig = new Zend_Config_Ini(CORE_CONFIGS_PATH.'/application.ini', null, $options);
Expand All @@ -183,7 +183,7 @@ public function step2Action()
$configGlobal = new Zend_Config_Ini(LOCAL_CONFIGS_PATH.'/application.local.ini', 'global');
Zend_Registry::set('configGlobal', $configGlobal);

$configDatabase = new Zend_Config_Ini(LOCAL_CONFIGS_PATH.'/database.local.ini', $configGlobal->environment);
$configDatabase = new Zend_Config_Ini(LOCAL_CONFIGS_PATH.'/database.local.ini', 'production');
Zend_Registry::set('configDatabase', $configDatabase);

require_once BASE_PATH.'/core/controllers/components/UpgradeComponent.php';
Expand All @@ -193,7 +193,8 @@ public function step2Action()
$upgradeComponent->upgrade(str_replace('.sql', '', basename($sqlFile)));

session_start();
$userModel = MidasLoader::loadModel('User');
require_once BASE_PATH.'/core/models/pdo/UserModel.php';
$userModel = new UserModel();
$this->userSession->Dao = $userModel->createUser(
$form->getValue('email'),
$form->getValue('userpassword1'),
Expand Down Expand Up @@ -259,7 +260,7 @@ public function step3Action()
$config->global->application->name = $form->getValue('name');
$config->global->default->timezone = $form->getValue('timezone');
$config->global->defaultassetstore->id = $assetstores[0]->getKey();
$config->global->environment = $form->getValue('environment');
$config->global->environment = 'production';

$writer = new Zend_Config_Writer_Ini();
$writer->setConfig($config);
Expand Down
2 changes: 1 addition & 1 deletion core/models/base/UserModelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function createUser($email, $password, $firstname, $lastname, $admin = 0,
}

// Check if the user already exists based on the email address
if ($this->getByEmail($email) != null) {
if ($this->getByEmail($email) !== false) {
throw new Zend_Exception("User already exists.");
}

Expand Down

0 comments on commit 3b43a72

Please sign in to comment.