optimization: locale caching, so we don`t have to reparse instance-config every single time

This commit is contained in:
czaks 2015-04-05 16:52:35 +02:00
parent e997357084
commit 758cb94e01

View File

@ -96,6 +96,13 @@ function loadConfig() {
// 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';
$configstr = file_get_contents('inc/instance-config.php');
@ -110,6 +117,9 @@ function loadConfig() {
$config['locale'] = $matches[count($matches)-1];
}
file_put_contents($fn, $config['locale']);
}
if ($config['locale'] != $current_locale) {
$current_locale = $config['locale'];
init_locale($config['locale'], $error);