// Fix smarty cache after modules translation update

This commit is contained in:
Rémi Gaillard
2013-04-17 14:44:20 +02:00
parent 49ff8ae4a1
commit f83b91ae51
3 changed files with 11 additions and 2 deletions
+2
View File
@@ -801,6 +801,8 @@ class LanguageCore extends ObjectModel
$files_list = $gz->listContent(); $files_list = $gz->listContent();
if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false)) if (!$gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
$errors[] = Tools::displayError('Cannot decompress the translation file for the following language: ').(string)$iso; $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)) if (!Language::checkAndAddLanguage((string)$iso, $lang_pack, false, $params))
$errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso; $errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$iso;
else else
+1 -1
View File
@@ -2117,7 +2117,7 @@ exit;
* *
* @param Smarty $smarty * @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)) if (is_null($smarty))
$smarty = Context::getContext()->smarty; $smarty = Context::getContext()->smarty;
@@ -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())) if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent()))
continue; continue;
// Clear smarty modules cache
Tools::clearCache();
if (Validate::isLanguageFileName($filename)) if (Validate::isLanguageFileName($filename))
{ {
if (!Language::checkAndAddLanguage($iso_code)) if (!Language::checkAndAddLanguage($iso_code))
@@ -735,13 +738,14 @@ class AdminTranslationsControllerCore extends AdminController
$this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message; $this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message;
else else
{ {
if (!Language::checkAndAddLanguage($arr_import_lang[0])) if (!Language::checkAndAddLanguage($arr_import_lang[0]))
$conf = 20; $conf = 20;
else else
{ {
// Reset cache // Reset cache
Language::loadLanguages(); Language::loadLanguages();
// Clear smarty modules cache
Tools::clearCache();
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list); AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
if ($tab_errors = AdminTranslationsController::addNewTabs($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) foreach ($arr_files as $value)
$this->findAndWriteTranslationsIntoFile($value['file_name'], $value['files'], $value['theme'], $value['module'], $value['dir']); $this->findAndWriteTranslationsIntoFile($value['file_name'], $value['files'], $value['theme'], $value['module'], $value['dir']);
// Clear modules cache
Tools::clearCache();
// Redirect // Redirect
if (Tools::getValue('submitTranslationsModulesAndStay')) if (Tools::getValue('submitTranslationsModulesAndStay'))
$this->redirect(true); $this->redirect(true);