From 4772fad3a34def41588ea49c0d5bd2f46f50a2d2 Mon Sep 17 00:00:00 2001 From: rMalie Date: Thu, 2 Feb 2012 09:31:18 +0000 Subject: [PATCH] // Add a lock on install process steps to be sure that a process can't be called if the first one isn't finished git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12916 b9a71923-0436-4b27-9f14-aed3839534dd --- install-dev/classes/session.php | 11 ++++- install-dev/controllers/http/process.php | 54 ++++++++++++++---------- install-dev/theme/js/process.js | 2 +- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/install-dev/classes/session.php b/install-dev/classes/session.php index f0eb1eb58..38869f6dc 100644 --- a/install-dev/classes/session.php +++ b/install-dev/classes/session.php @@ -45,9 +45,16 @@ class InstallSession session_start(); } - public function __get($varname) + public function &__get($varname) { - return isset($_SESSION[$varname]) ? $_SESSION[$varname] : null; + if (isset($_SESSION[$varname])) + $ref = &$_SESSION[$varname]; + else + { + $null = null; + $ref = &$null; + } + return $ref; } public function __set($varname, $value) diff --git a/install-dev/controllers/http/process.php b/install-dev/controllers/http/process.php index 9528c4162..ee2752cf9 100644 --- a/install-dev/controllers/http/process.php +++ b/install-dev/controllers/http/process.php @@ -55,6 +55,20 @@ class InstallControllerHttpProcess extends InstallControllerHttp return false; } + public function initializeContext() + { + global $smarty; + + Context::getContext()->shop = new Shop(1); + Configuration::loadConfiguration(); + Context::getContext()->language = new Language(Configuration::get('PS_LANG_DEFAULT')); + Context::getContext()->country = new Country('PS_COUNTRY_DEFAULT'); + Context::getContext()->cart = new Cart(); + + require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php'; + Context::getContext()->smarty = $smarty; + } + public function process() { if (file_exists(_PS_ROOT_DIR_.'/'.self::SETTINGS_FILE)) @@ -62,18 +76,22 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (Tools::getValue('installDatabase')) $this->processInstallDatabase(); - else if (Tools::getValue('populateDatabase')) + else if (Tools::getValue('populateDatabase') && !empty($this->session->process_validated['installDatabase'])) $this->processPopulateDatabase(); - else if (Tools::getValue('configureShop')) + else if (Tools::getValue('configureShop') && !empty($this->session->process_validated['populateDatabase'])) $this->processConfigureShop(); - else if (Tools::getValue('installModules')) + else if (Tools::getValue('installModules') && !empty($this->session->process_validated['configureShop'])) $this->processInstallModules(); - else if (Tools::getValue('installFixtures')) + else if (Tools::getValue('installFixtures') && !empty($this->session->process_validated['installModules'])) $this->processInstallFixtures(); - else if (Tools::getValue('installTheme')) + else if (Tools::getValue('installTheme') && !empty($this->session->process_validated['installFixtures'])) $this->processInstallTheme(); - else if (Tools::getValue('preactivation')) - $this->processPreactivation(); + else + { + // With no parameters, we consider that we are doing a new install, so session where the last process step + // was stored can be cleaned + $this->session->process_validated = array(); + } } /** @@ -94,6 +112,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (!$success || $this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + $this->session->process_validated['installDatabase'] = true; $this->ajaxJsonAnswer(true); } @@ -113,6 +132,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (!$result || $this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); $this->session->xml_loader_ids = $this->model_install->xml_loader_ids; + $this->session->process_validated['populateDatabase'] = true; $this->ajaxJsonAnswer(true); } @@ -143,23 +163,10 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (!$success || $this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + $this->session->process_validated['configureShop'] = true; $this->ajaxJsonAnswer(true); } - public function initializeContext() - { - global $smarty; - - Context::getContext()->shop = new Shop(1); - Configuration::loadConfiguration(); - Context::getContext()->language = new Language(Configuration::get('PS_LANG_DEFAULT')); - Context::getContext()->country = new Country('PS_COUNTRY_DEFAULT'); - Context::getContext()->cart = new Cart(); - - require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php'; - Context::getContext()->smarty = $smarty; - } - /** * PROCESS : installModules * Install all modules in ~/modules/ directory @@ -173,6 +180,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp if (!$this->model_install->installModules() || $this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + $this->session->process_validated['installModules'] = true; $this->ajaxJsonAnswer(true); } @@ -187,6 +195,7 @@ class InstallControllerHttpProcess extends InstallControllerHttp $this->model_install->xml_loader_ids = $this->session->xml_loader_ids; if (!$this->model_install->installFixtures() || $this->model_install->getErrors()) $this->ajaxJsonAnswer(false, $this->model_install->getErrors()); + $this->session->process_validated['installFixtures'] = true; $this->ajaxJsonAnswer(true); } @@ -241,7 +250,8 @@ class InstallControllerHttpProcess extends InstallControllerHttp $this->process_steps[] = array('key' => 'installModules', 'lang' => $this->l('Install modules')); if ($this->session->install_type == 'full') $this->process_steps[] = array('key' => 'installFixtures', 'lang' => $this->l('Install demonstration data')); - $this->process_steps[] = array('key' => 'installTheme', 'lang' => $this->l('CInstall theme')); + $this->process_steps[] = array('key' => 'installTheme', 'lang' => $this->l('Install theme')); + $this->displayTemplate('process'); } } diff --git a/install-dev/theme/js/process.js b/install-dev/theme/js/process.js index a1dbb201c..8d21b2053 100644 --- a/install-dev/theme/js/process.js +++ b/install-dev/theme/js/process.js @@ -35,7 +35,7 @@ function process_install(step) success: function(json) { // No error during this step - if (json && json.success) + if (json && json.success === true) { $('#process_step_'+step.key).show().addClass('success'); current_step++;