Browse Source

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

pull/40/head
czaks 9 years ago
parent
commit
758cb94e01
  1. 10
      inc/functions.php

10
inc/functions.php

@ -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);

Loading…
Cancel
Save