Skip to content

Commit

Permalink
MDL-32377 do not store incomplete component strings without local pac…
Browse files Browse the repository at this point in the history
…ks in on-disk string cache
  • Loading branch information
skodak committed Apr 16, 2012
1 parent 668a499 commit ea7d4b0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/moodlelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -6293,7 +6293,7 @@ public function load_component_strings($component, $lang, $disablecache=false, $
$component = $plugintype . '_' . $pluginname;
}

if (!$disablecache) {
if (!$disablecache and !$disablelocal) {
// try in-memory cache first
if (isset($this->cache[$lang][$component])) {
$this->countmemcache++;
Expand Down Expand Up @@ -6384,12 +6384,14 @@ public function load_component_strings($component, $lang, $disablecache=false, $
// 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;
}
Expand Down

0 comments on commit ea7d4b0

Please sign in to comment.