// Fix installer with clear mode to false
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12935 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -88,7 +88,9 @@ class InstallControllerHttpDatabase extends InstallControllerHttp
|
||||
$this->session->database_password,
|
||||
$this->session->database_prefix,
|
||||
$this->session->database_engine,
|
||||
$this->session->database_clear
|
||||
|
||||
// We do not want to validate table prefix if we are already in install process
|
||||
($this->session->step == 'process') ? true : $this->session->database_clear
|
||||
);
|
||||
|
||||
return count($this->errors) ? false : true;
|
||||
|
||||
@@ -74,7 +74,9 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
if (file_exists(_PS_ROOT_DIR_.'/'.self::SETTINGS_FILE))
|
||||
require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
|
||||
|
||||
if (Tools::getValue('installDatabase'))
|
||||
if (Tools::getValue('generateSettingsFile'))
|
||||
$this->processGenerateSettingsFile();
|
||||
else if (Tools::getValue('installDatabase') && !empty($this->session->process_validated['generateSettingsFile']))
|
||||
$this->processInstallDatabase();
|
||||
else if (Tools::getValue('populateDatabase') && !empty($this->session->process_validated['installDatabase']))
|
||||
$this->processPopulateDatabase();
|
||||
@@ -95,22 +97,32 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
}
|
||||
|
||||
/**
|
||||
* PROCESS : installDatabase
|
||||
* Generate settings file and create database structure
|
||||
* PROCESS : generateSettingsFile
|
||||
*/
|
||||
public function processInstallDatabase()
|
||||
public function processGenerateSettingsFile()
|
||||
{
|
||||
$success = $this->model_install->installDatabase(
|
||||
$success = $this->model_install->generateSettingsFile(
|
||||
$this->session->database_server,
|
||||
$this->session->database_login,
|
||||
$this->session->database_password,
|
||||
$this->session->database_name,
|
||||
$this->session->database_prefix,
|
||||
$this->session->database_engine,
|
||||
$this->session->database_clear
|
||||
$this->session->database_engine
|
||||
);
|
||||
|
||||
if (!$success || $this->model_install->getErrors())
|
||||
if (!$success)
|
||||
$this->ajaxJsonAnswer(false);
|
||||
$this->session->process_validated['generateSettingsFile'] = true;
|
||||
$this->ajaxJsonAnswer(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* PROCESS : installDatabase
|
||||
* Create database structure
|
||||
*/
|
||||
public function processInstallDatabase()
|
||||
{
|
||||
if (!$this->model_install->installDatabase($this->session->database_clear) || $this->model_install->getErrors())
|
||||
$this->ajaxJsonAnswer(false, $this->model_install->getErrors());
|
||||
$this->session->process_validated['installDatabase'] = true;
|
||||
$this->ajaxJsonAnswer(true);
|
||||
@@ -245,6 +257,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp
|
||||
public function display()
|
||||
{
|
||||
$this->process_steps = array();
|
||||
$this->process_steps[] = array('key' => 'generateSettingsFile', 'lang' => $this->l('Create settings.inc file'));
|
||||
$this->process_steps[] = array('key' => 'installDatabase', 'lang' => $this->l('Create database tables'));
|
||||
$this->process_steps[] = array('key' => 'populateDatabase', 'lang' => $this->l('Populate database tables'));
|
||||
$this->process_steps[] = array('key' => 'configureShop', 'lang' => $this->l('Configure shop informations'));
|
||||
|
||||
@@ -29,47 +29,6 @@ class InstallModelInstall extends InstallAbstractModel
|
||||
{
|
||||
const SETTINGS_FILE = 'config/settings.inc.php';
|
||||
|
||||
/**
|
||||
* PROCESS : installDatabase
|
||||
* Generate settings file and create database structure
|
||||
*/
|
||||
public function installDatabase($database_server, $database_login, $database_password, $database_name, $database_prefix, $database_engine, $clear_database = false)
|
||||
{
|
||||
// Generate settings file
|
||||
$this->generateSettingsFile($database_server, $database_login, $database_password, $database_name, $database_prefix, $database_engine);
|
||||
|
||||
// Clear database (only tables with same prefix)
|
||||
require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
|
||||
if ($clear_database)
|
||||
$this->clearDatabase();
|
||||
|
||||
// Install database structure
|
||||
$sql_loader = new InstallSqlLoader();
|
||||
$sql_loader->setMetaData(array(
|
||||
'PREFIX_' => _DB_PREFIX_,
|
||||
'ENGINE_TYPE' => _MYSQL_ENGINE_,
|
||||
));
|
||||
|
||||
try
|
||||
{
|
||||
$sql_loader->parse_file(_PS_INSTALL_DATA_PATH_.'db_structure.sql');
|
||||
}
|
||||
catch (PrestashopInstallerException $e)
|
||||
{
|
||||
$this->setError($this->language->l('Database structure file not found'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($errors = $sql_loader->getErrors())
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
$this->setError($this->language->l('An SQL error occured: <i>%1$s</i>', $error['error']));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate settings file
|
||||
*/
|
||||
@@ -124,6 +83,44 @@ class InstallModelInstall extends InstallAbstractModel
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* PROCESS : installDatabase
|
||||
* Generate settings file and create database structure
|
||||
*/
|
||||
public function installDatabase($clear_database = false)
|
||||
{
|
||||
// Clear database (only tables with same prefix)
|
||||
require_once _PS_ROOT_DIR_.'/'.self::SETTINGS_FILE;
|
||||
if ($clear_database)
|
||||
$this->clearDatabase();
|
||||
|
||||
// Install database structure
|
||||
$sql_loader = new InstallSqlLoader();
|
||||
$sql_loader->setMetaData(array(
|
||||
'PREFIX_' => _DB_PREFIX_,
|
||||
'ENGINE_TYPE' => _MYSQL_ENGINE_,
|
||||
));
|
||||
|
||||
try
|
||||
{
|
||||
$sql_loader->parse_file(_PS_INSTALL_DATA_PATH_.'db_structure.sql');
|
||||
}
|
||||
catch (PrestashopInstallerException $e)
|
||||
{
|
||||
$this->setError($this->language->l('Database structure file not found'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($errors = $sql_loader->getErrors())
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
$this->setError($this->language->l('An SQL error occured: <i>%1$s</i>', $error['error']));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear database (only tables with same prefix)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user