language : correct the segfault if the cache is changed (missing domframework part and wrong dir provided to bindtextdomain

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2957 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2016-07-26 07:20:38 +00:00
parent 4bc2fcaf6c
commit 3cc8300ed6

View File

@@ -189,7 +189,7 @@ class language
}
/** This function manage the cache of $package.mo files as Apache cache them
It return the $moFile to use
It return the directory to use
@param string $languageCode Language with format "fr_FR"
@param string|null $package The package name of the soft ($package.mo
file). "messages" by default
@@ -214,13 +214,12 @@ class language
$category = $this->languageCategoryText ($category);
$temporaries = glob ("$repLocale/$languageCode.$codeset/$category/*-*.mo");
$moFile = "$repLocale/$languageCode.$codeset/$category/$package.mo";
if (! file_exists ($moFile))
return "";
$linkBase = $this->cacheDir."/".filemtime($moFile)."/";
$linkEnd = "$languageCode.$codeset/$category/$package.mo";
$link = $linkBase.$linkEnd;
if (! file_exists ($moFile))
{
return "";
}
clearstatcache (false, $moFile);
// Manage the cache directory
if (! file_exists (dirname ($link)))
{
@@ -235,6 +234,7 @@ class language
if (! file_exists ($link) || ! is_readable ($link) ||
filemtime ($moFile) > filemtime ($link))
{
// Do not remove immediately the old files : they can be used by Apache
$files = glob ($this->cacheDir."/*/".$linkEnd);
foreach ($files as $file)
{
@@ -252,7 +252,6 @@ class language
return $link;
}
}
clearstatcache (false, $moFile);
return $moFile;
}
@@ -318,10 +317,12 @@ class language
// Cache the domframework's .mo file too
$dfFile = $this->languageCache ($languageCode, "domframework", LC_MESSAGES,
dirname (__FILE__)."/locale");
$this->languageActivation ($dfFile, $languageCode, LC_MESSAGES,
dirname (__FILE__)."/locale");
$dfDir = dirname (dirname (dirname ($dfFile)));
$this->languageActivation ($dfFile, $languageCode, LC_MESSAGES, $dfDir);
$languageCodeFichier = $this->languageCache ($languageCode, $package);
$this->languageActivation ($languageCodeFichier, $languageCode);
$languageCodeDir = dirname (dirname (dirname ($languageCodeFichier)));
$this->languageActivation ($languageCodeFichier, $languageCode, LC_MESSAGES,
$languageCodeDir);
return $languageCode;
}