Merge branch 'w16_MDL-32377_m23_strcache' of git://github.com/skodak/moodle
This commit is contained in:
+13
-8
@@ -6293,7 +6293,7 @@ class core_string_manager implements string_manager {
|
||||
$component = $plugintype . '_' . $pluginname;
|
||||
}
|
||||
|
||||
if (!$disablecache) {
|
||||
if (!$disablecache and !$disablelocal) {
|
||||
// try in-memory cache first
|
||||
if (isset($this->cache[$lang][$component])) {
|
||||
$this->countmemcache++;
|
||||
@@ -6384,12 +6384,14 @@ class core_string_manager implements string_manager {
|
||||
// we do not want any extra strings from other languages - everything must be in en lang pack
|
||||
$string = array_intersect_key($string, $originalkeys);
|
||||
|
||||
// now we have a list of strings from all possible sources. put it into both in-memory and on-disk
|
||||
// caches so we do not need to do all this merging and dependencies resolving again
|
||||
$this->cache[$lang][$component] = $string;
|
||||
if ($this->usediskcache) {
|
||||
check_dir_exists("$this->cacheroot/$lang");
|
||||
file_put_contents("$this->cacheroot/$lang/$component.php", "<?php \$this->cache['$lang']['$component'] = ".var_export($string, true).";");
|
||||
if (!$disablelocal) {
|
||||
// now we have a list of strings from all possible sources. put it into both in-memory and on-disk
|
||||
// caches so we do not need to do all this merging and dependencies resolving again
|
||||
$this->cache[$lang][$component] = $string;
|
||||
if ($this->usediskcache) {
|
||||
check_dir_exists("$this->cacheroot/$lang");
|
||||
file_put_contents("$this->cacheroot/$lang/$component.php", "<?php \$this->cache['$lang']['$component'] = ".var_export($string, true).";");
|
||||
}
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
@@ -6469,8 +6471,11 @@ class core_string_manager implements string_manager {
|
||||
return 'en';
|
||||
}
|
||||
if ($this->usediskcache) {
|
||||
// maybe the on-disk cache is dirty - let the last attempt be to find the string in original sources
|
||||
// maybe the on-disk cache is dirty - let the last attempt be to find the string in original sources,
|
||||
// do NOT write the results to disk cache because it may end up in race conditions see MDL-31904
|
||||
$this->usediskcache = false;
|
||||
$string = $this->load_component_strings($component, $lang, true);
|
||||
$this->usediskcache = true;
|
||||
}
|
||||
if (!isset($string[$identifier])) {
|
||||
// the string is still missing - should be fixed by developer
|
||||
|
||||
Reference in New Issue
Block a user