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