mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-70137 cache: Write config to temp file and move into place
This commit is contained in:
parent
db8377b53e
commit
b8bf6f9c42
6
cache/locallib.php
vendored
6
cache/locallib.php
vendored
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user