Commit 8752df87 authored by victor's avatar victor 🙇

Merge branch 'MDL-70137-310-2' of git:// into MOODLE_310_STABLE

parents fcb69980 511dab1c
......@@ -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();
......@@ -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);
$locking->unlock('configwrite', 'config');
@chmod($cachefile, $CFG->filepermissions);
@chmod($tempcachefile, $CFG->filepermissions);
rename($tempcachefile, $cachefile);
// Tell PHP to recompile the script.
} else {
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment