optimization: locale caching, so we don`t have to reparse instance-config every single time
This commit is contained in:
parent
e997357084
commit
758cb94e01
@ -96,6 +96,13 @@ function loadConfig() {
|
|||||||
|
|
||||||
// Initialize locale as early as possible
|
// Initialize locale as early as possible
|
||||||
|
|
||||||
|
// Those calls are expensive. Unfortunately, our cache system is not initialized at this point.
|
||||||
|
// So, we may store the locale in a tmp/ filesystem.
|
||||||
|
|
||||||
|
if (file_exists($fn = 'tmp/cache/locale_' . ( isset($board['uri']) ? $board['uri'] : '' ) ) ) {
|
||||||
|
$config['locale'] = file_get_contents($fn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$config['locale'] = 'en';
|
$config['locale'] = 'en';
|
||||||
|
|
||||||
$configstr = file_get_contents('inc/instance-config.php');
|
$configstr = file_get_contents('inc/instance-config.php');
|
||||||
@ -110,6 +117,9 @@ function loadConfig() {
|
|||||||
$config['locale'] = $matches[count($matches)-1];
|
$config['locale'] = $matches[count($matches)-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file_put_contents($fn, $config['locale']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($config['locale'] != $current_locale) {
|
if ($config['locale'] != $current_locale) {
|
||||||
$current_locale = $config['locale'];
|
$current_locale = $config['locale'];
|
||||||
init_locale($config['locale'], $error);
|
init_locale($config['locale'], $error);
|
||||||
|
Loading…
Reference in New Issue
Block a user