Commit 8752df87 authored by victor's avatar victor 🙇

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

parents fcb69980 511dab1c
...@@ -323,7 +323,7 @@ class cache_config { ...@@ -323,7 +323,7 @@ class cache_config {
* @throws cache_exception * @throws cache_exception
*/ */
protected function include_configuration() { 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. // We need to allow for late static bindings to allow for class path mudling happending for unit tests.
$cachefile = static::get_config_file_path(); $cachefile = static::get_config_file_path();
...@@ -594,4 +594,4 @@ class cache_config { ...@@ -594,4 +594,4 @@ class cache_config {
} }
throw new cache_exception('ex_nodefaultlock'); throw new cache_exception('ex_nodefaultlock');
} }
} }
\ No newline at end of file
...@@ -102,13 +102,15 @@ class cache_config_writer extends cache_config { ...@@ -102,13 +102,15 @@ class cache_config_writer extends cache_config {
$factory = cache_factory::instance(); $factory = cache_factory::instance();
$locking = $factory->create_lock_instance($lockconf); $locking = $factory->create_lock_instance($lockconf);
if ($locking->lock('configwrite', 'config', true)) { if ($locking->lock('configwrite', 'config', true)) {
$tempcachefile = "{$cachefile}.tmp";
// Its safe to use w mode here because we have already acquired the lock. // 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); fwrite($handle, $content);
fflush($handle); fflush($handle);
fclose($handle); fclose($handle);
$locking->unlock('configwrite', 'config'); $locking->unlock('configwrite', 'config');
@chmod($cachefile, $CFG->filepermissions); @chmod($tempcachefile, $CFG->filepermissions);
rename($tempcachefile, $cachefile);
// Tell PHP to recompile the script. // Tell PHP to recompile the script.
core_component::invalidate_opcode_php_cache($cachefile); core_component::invalidate_opcode_php_cache($cachefile);
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment