Merge branch 'MDL-70137-39-2' of git://github.com/andrewnicols/moodle into MOODLE_39_STABLE

This commit is contained in:
Víctor Déniz
2020-11-06 19:17:44 +00:00
2 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -323,7 +323,7 @@ class cache_config {
* @throws cache_exception
*/
protected function include_configuration() {
$configuration = array();
$configuration = null;
// We need to allow for late static bindings to allow for class path mudling happending for unit tests.
$cachefile = static::get_config_file_path();
@@ -594,4 +594,4 @@ class cache_config {
}
throw new cache_exception('ex_nodefaultlock');
}
}
}
+4 -2
View File
@@ -102,13 +102,15 @@ class cache_config_writer extends cache_config {
$factory = cache_factory::instance();
$locking = $factory->create_lock_instance($lockconf);
if ($locking->lock('configwrite', 'config', true)) {
$tempcachefile = "{$cachefile}.tmp";
// Its safe to use w mode here because we have already acquired the lock.
$handle = fopen($cachefile, 'w');
$handle = fopen($tempcachefile, 'w');
fwrite($handle, $content);
fflush($handle);
fclose($handle);
$locking->unlock('configwrite', 'config');
@chmod($cachefile, $CFG->filepermissions);
@chmod($tempcachefile, $CFG->filepermissions);
rename($tempcachefile, $cachefile);
// Tell PHP to recompile the script.
core_component::invalidate_opcode_php_cache($cachefile);
} else {