Skip to content

Commit

Permalink
Merge branch 'MDL-70137-39-2' of git://github.com/andrewnicols/moodle…
Browse files Browse the repository at this point in the history
… into MOODLE_39_STABLE
  • Loading branch information
vmdef committed Nov 6, 2020
2 parents 7bc714a + 463b232 commit d727c1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cache/classes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public function get_site_identifier() {
* @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();

Expand Down Expand Up @@ -594,4 +594,4 @@ public function get_default_lock() {
}
throw new cache_exception('ex_nodefaultlock');
}
}
}
6 changes: 4 additions & 2 deletions cache/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ protected function config_save() {
$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 {
Expand Down

0 comments on commit d727c1e

Please sign in to comment.