From 608fa5eaed72e7941d51f45eeca86efb0197b4e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Nov 2014 10:25:56 +0100 Subject: [PATCH] Fix: Avoid to load language when we can not. --- htdocs/core/class/translate.class.php | 6 ++++++ htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 563c749ae92..7347b065a79 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -197,6 +197,12 @@ class Translate if ($alt < 1 && isset($langarray[1]) && strtolower($langarray[0]) == strtolower($langarray[1])) $alt=1; if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt=2; + if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir + { + dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING); + return -1; + } + foreach($this->dir as $keydir => $searchdir) { // Directory of translation files diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e95ec86066c..df7eafe3d9d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2811,7 +2811,7 @@ class Societe extends CommonObject } else // For backward compatibility { - dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_WARNING); + dol_syslog("Your country setup use an old syntax. Reedit it using setup area.", LOG_ERR); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $country_code=getCountry($country_id,2,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore $country_label=getCountry($country_id,0,$this->db); // This need a SQL request, but it's the old feature that should not be used anymore