From f83b91ae51d81dd3af2fb5ac1930e2f557cb305e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 17 Apr 2013 14:44:20 +0200 Subject: [PATCH] // Fix smarty cache after modules translation update --- classes/Language.php | 2 ++ classes/Tools.php | 2 +- controllers/admin/AdminTranslationsController.php | 9 ++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/classes/Language.php b/classes/Language.php index 281343fed..3ce4b1908 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -801,6 +801,8 @@ class LanguageCore extends ObjectModel $files_list = $gz->listContent(); if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) $errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso; + // Clear smarty modules cache + Tools::clearCache(); if (!Language::checkAndAddLanguage((string)$iso, $lang_pack, false, $params)) $errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso; else diff --git a/classes/Tools.php b/classes/Tools.php index 08705746b..49db8cd9e 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2117,7 +2117,7 @@ exit; * * @param Smarty $smarty */ - public static function clearCache($smarty, $tpl = false, $cache_id = null, $compile_id = null) + public static function clearCache($smarty = null, $tpl = false, $cache_id = null, $compile_id = null) { if (is_null($smarty)) $smarty = Context::getContext()->smarty; diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index a02e767dd..df8898e62 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -686,6 +686,9 @@ class AdminTranslationsControllerCore extends AdminController if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent())) continue; + // Clear smarty modules cache + Tools::clearCache(); + if (Validate::isLanguageFileName($filename)) { if (!Language::checkAndAddLanguage($iso_code)) @@ -735,13 +738,14 @@ class AdminTranslationsControllerCore extends AdminController $this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message; else { - if (!Language::checkAndAddLanguage($arr_import_lang[0])) $conf = 20; else { // Reset cache Language::loadLanguages(); + // Clear smarty modules cache + Tools::clearCache(); AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list); if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list)) @@ -1340,6 +1344,9 @@ class AdminTranslationsControllerCore extends AdminController foreach ($arr_files as $value) $this->findAndWriteTranslationsIntoFile($value['file_name'], $value['files'], $value['theme'], $value['module'], $value['dir']); + // Clear modules cache + Tools::clearCache(); + // Redirect if (Tools::getValue('submitTranslationsModulesAndStay')) $this->redirect(true);