mirror of
https://github.com/moodle/moodle.git
synced 2025-03-22 08:30:04 +01:00
Merge branch 'MDL-51111-muc-reset' of https://github.com/brendanheywood/moodle
This commit is contained in:
commit
f86591b516
10
cache/locallib.php
vendored
10
cache/locallib.php
vendored
@ -68,6 +68,7 @@ class cache_config_writer extends cache_config {
|
||||
*/
|
||||
protected function config_save() {
|
||||
global $CFG;
|
||||
static $confighash = '';
|
||||
$cachefile = static::get_config_file_path();
|
||||
$directory = dirname($cachefile);
|
||||
if ($directory !== $CFG->dataroot && !file_exists($directory)) {
|
||||
@ -86,6 +87,15 @@ class cache_config_writer extends cache_config {
|
||||
// Prepare the file content.
|
||||
$content = "<?php defined('MOODLE_INTERNAL') || die();\n \$configuration = ".var_export($configuration, true).";";
|
||||
|
||||
// Do both file content and hash based detection because this might be called
|
||||
// many times within a single request.
|
||||
$hash = sha1($content);
|
||||
if (($hash === $confighash) || (file_exists($cachefile) && $content === file_get_contents($cachefile))) {
|
||||
// Config is unchanged so don't bother locking and writing.
|
||||
$confighash = $hash;
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to create a temporary cache lock instance for use here. Remember we are generating the config file
|
||||
// it doesn't exist and thus we can't use the normal API for this (it'll just try to use config).
|
||||
$lockconf = reset($this->configlocks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user