Skip to content

Commit

Permalink
[*] Installer : Set context in upgrader
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Apr 10, 2013
1 parent 8674313 commit 17012ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classes/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static function getModuleTranslation($module, $string, $source, $sprintf
static $translations_merged = array();

$name = $module instanceof Module ? $module->name : $module;
if (!isset($translations_merged[$name]))
if (!isset($translations_merged[$name]) && isset(Context::getContext()->language))
{
$filesByPriority = array(
// Translations in theme
Expand Down
10 changes: 6 additions & 4 deletions classes/module/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ abstract class ModuleCore
public function __construct($name = null, Context $context = null)
{
// Load context and smarty
$this->context = $context ? $context : Context::getContext();
$this->smarty = $this->context->smarty->createData($this->context->smarty);
$this->context = $context ? $context : Context::getContext();
if (is_object($this->context->smarty))
$this->smarty = $this->context->smarty->createData($this->context->smarty);

// If the module has no name we gave him its id as name
if ($this->name == null)
Expand All @@ -152,8 +153,9 @@ public function __construct($name = null, Context $context = null)
// If cache is not generated, we generate it
if (self::$modules_cache == null && !is_array(self::$modules_cache))
{
// Join clause is done to check if the module is activated in current shop context
$sql_limit_shop = 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'module_shop` ms WHERE m.`id_module` = ms.`id_module` AND ms.`id_shop` = '.(int)Context::getContext()->shop->id;
// Join clause is done to check if the module is activated in current shop context
$sql_limit_shop = 'SELECT COUNT(*) FROM `'._DB_PREFIX_.'module_shop` ms WHERE m.`id_module` = ms.`id_module` AND ms.`id_shop` = '.((is_object(Context::getContext()->shop) && $id = (int)Context::getContext()->shop->id) ? $id : 1);

$sql = 'SELECT m.`id_module`, m.`name`, ('.$sql_limit_shop.') as total FROM `'._DB_PREFIX_.'module` m';

// Result is cached
Expand Down
2 changes: 1 addition & 1 deletion install-dev/install_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
* International Registered Trademark & Property of PrestaShop SA
*/

define('_PS_INSTALL_VERSION_', '1.5.4.0');
define('_PS_INSTALL_VERSION_', '1.5.4.1');
22 changes: 22 additions & 0 deletions install-dev/upgrade/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,28 @@
define('_PS_CACHE_ENABLED_', '0');
if(!defined('_MYSQL_ENGINE_'))
define('_MYSQL_ENGINE_', 'MyISAM');

global $smarty;
// Clean all cache values
Cache::clean('*');

Context::getContext()->shop = new Shop(1);
Shop::setContext(Shop::CONTEXT_SHOP, 1);
Configuration::loadConfiguration();
if (!isset(Context::getContext()->language) || !Validate::isLoadedObject(Context::getContext()->language))
if ($id_lang = (int)Configuration::get('PS_LANG_DEFAULT'))
Context::getContext()->language = new Language($id_lang);
if (!isset(Context::getContext()->country) || !Validate::isLoadedObject(Context::getContext()->country))
if ($id_country = (int)Configuration::get('PS_COUNTRY_DEFAULT'))
Context::getContext()->country = new Country((int)$id_country);

Context::getContext()->cart = new Cart();
Context::getContext()->employee = new Employee(1);
if (!defined('_PS_SMARTY_FAST_LOAD_'))
define('_PS_SMARTY_FAST_LOAD_', true);
require_once _PS_ROOT_DIR_.'/config/smarty.config.inc.php';

Context::getContext()->smarty = $smarty;

if(isset($_GET['customModule']) AND $_GET['customModule'] == 'desactivate')
{
Expand Down

0 comments on commit 17012ea

Please sign in to comment.