diff --git a/classes/module/Module.php b/classes/module/Module.php index b323204b6..8fcbddd8c 100644 --- a/classes/module/Module.php +++ b/classes/module/Module.php @@ -292,15 +292,17 @@ abstract class ModuleCore else { if (!$upgrade_detail['number_upgraded']) - $this->_errors[] = $this->l('None upgrades have been applied'); + $this->_errors[] = $this->l('No upgrade has been applied'); else { - $this->_errors[] = $this->l('Upgraded from: ').$upgrade_detail['upgraded_from'].$this->l(' to '). - $upgrade_detail['upgraded_to']; + $this->_errors[] = sprintf($this->l('Upgraded from: %S to %s'), $upgrade_detail['upgraded_from'], $upgrade_detail['upgraded_to']); $this->_errors[] = $upgrade_detail['number_upgrade_left'].' '.$this->l('upgrade left'); } - $this->_errors[] = $this->l('To prevent any problem, this module has been turned off'); + if ($upgrade_detail['duplicate']) + $this->_errors[] = sprintf(Tools::displayError('Module %s cannot be upgraded this time: please refresh this page to update it.'), $this->name); + else + $this->_errors[] = $this->l('To prevent any problem, this module has been turned off'); } } } @@ -348,19 +350,21 @@ abstract class ModuleCore $upgrade = &self::$modules_cache[$this->name]['upgrade']; foreach ($upgrade['upgrade_file_left'] as $num => $file_detail) { - // Default variable required in the included upgrade file need to be set by default there: - // upgrade_version, success_upgrade - $upgrade_result = false; + if (function_exists($file_detail['upgrade_function'])) + { + $upgrade['success'] = false; + $upgrade['duplicate'] = true; + break; + } include($file_detail['file']); // Call the upgrade function if defined + $upgrade['success'] = false; if (function_exists($file_detail['upgrade_function'])) - $upgrade_result = $file_detail['upgrade_function']($this); - - $upgrade['success'] = $upgrade_result; + $upgrade['success'] = $file_detail['upgrade_function']($this); // Set detail when an upgrade succeed or failed - if ($upgrade_result) + if ($upgrade['success']) { $upgrade['number_upgraded'] += 1; $upgrade['upgraded_to'] = $file_detail['version']; @@ -378,6 +382,7 @@ abstract class ModuleCore } $upgrade['number_upgrade_left'] = count($upgrade['upgrade_file_left']); + // Update module version in DB with the last succeed upgrade if ($upgrade['upgraded_to']) Module::upgradeModuleVersion($this->name, $upgrade['upgraded_to']); @@ -396,9 +401,9 @@ abstract class ModuleCore public static function upgradeModuleVersion($name, $version) { return Db::getInstance()->execute(' - UPDATE `'._DB_PREFIX_.'module` m - SET m.version = \''.bqSQL($version).'\' - WHERE m.name = \''.bqSQL($name).'\''); + UPDATE `'._DB_PREFIX_.'module` m + SET m.version = \''.bqSQL($version).'\' + WHERE m.name = \''.bqSQL($name).'\''); } /** diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index f76c9133b..dc2b3cdd9 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -630,9 +630,8 @@ class AdminModulesControllerCore extends AdminController if (!$download_ok) $this->errors[] = $this->l('Error on downloading the lastest version'); - else - if(!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) - $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); + elseif (!$this->extractArchive(_PS_MODULE_DIR_.$modaddons->name.'.zip', false)) + $this->errors[] = $this->l(sprintf("Module %s can't be upgraded: ", $modaddons->name)); } } } @@ -674,18 +673,18 @@ class AdminModulesControllerCore extends AdminController // Get the return value of current method $echo = $module->{$method}(); - + // After a successful install of a single module that has a configuration method, to the configuration page if ($key == 'install' && $echo === true && strpos(Tools::getValue('install'), '|') === false && method_exists($module, 'getContent')) Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&configure='.$module->name.'&conf=12'); } - + // If the method called is "configure" (getContent method), we show the html code of configure page if ($key == 'configure' && Module::isInstalled($module->name)) { if (isset($module->multishop_context)) $this->multishop_context = $module->multishop_context; - + $backlink = self::$currentIndex.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name; $hooklink = 'index.php?tab=AdminModulesPositions&token='.Tools::getAdminTokenLite('AdminModulesPositions').'&show_modules='.(int)$module->id; $tradlink = 'index.php?tab=AdminTranslations&token='.Tools::getAdminTokenLite('AdminTranslations').'&type=modules&lang='; @@ -768,10 +767,8 @@ class AdminModulesControllerCore extends AdminController Tools::redirectAdmin(self::$currentIndex.'&conf='.$return.'&token='.$this->token.'&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params); } - if(isset($_GET['update'])) - { + if (isset($_GET['update'])) Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&updated=1tab_module='.$module->tab.'&module_name='.$module->name.'&anchor=anchor'.ucfirst($module->name).(isset($modules_list_save) ? '&modules_list='.$modules_list_save : '').$params); - } } public function postProcess() @@ -779,7 +776,6 @@ class AdminModulesControllerCore extends AdminController // Parent Post Process parent::postProcess(); - // Get the list of installed module ans prepare it for ajax call. if (($list = Tools::getValue('installed_modules'))) Context::getContext()->smarty->assign('installed_modules', Tools::jsonEncode(explode('|', $list))); diff --git a/modules/blocklayered/config.xml b/modules/blocklayered/config.xml index da98eb84b..e6b78b59b 100644 --- a/modules/blocklayered/config.xml +++ b/modules/blocklayered/config.xml @@ -1,9 +1,9 @@ blocklayered - + - + 1 diff --git a/modules/homeslider/upgrade/install-1.2.1.php b/modules/homeslider/upgrade/install-1.2.1.php index 7817ecaf7..2d3d12abd 100644 --- a/modules/homeslider/upgrade/install-1.2.1.php +++ b/modules/homeslider/upgrade/install-1.2.1.php @@ -16,9 +16,9 @@ function upgrade_module_1_2_1($object) function homeslider_stripslashes_field($field) { - $quotes = array('\'\\\\\'\'', '\'\\\'\''); - $dquotes = array('\'\\"\'', '\'"\''); - $backslashes = array('\'\\\\\'', '\'\\\''); + $quotes = array('"\\\'"', '"\'"'); + $dquotes = array('\'\\\\"\'', '\'"\''); + $backslashes = array('"\\\\\\\\"', '"\\\\"'); return '`'.bqSQL($field).'` = replace(replace(replace(`'.bqSQL($field).'`, '.$quotes[0].', '.$quotes[1].'), '.$dquotes[0].', '.$dquotes[1].'), '.$backslashes[0].', '.$backslashes[1].')'; } \ No newline at end of file