Merge branch 'w31_MDL-40891_m24_mkdirrace' of https://github.com/skodak/moodle into MOODLE_24_STABLE
This commit is contained in:
Vendored
+2
-2
@@ -266,7 +266,7 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
|
||||
$this->definition = $definition;
|
||||
$hash = preg_replace('#[^a-zA-Z0-9]+#', '_', $this->definition->get_id());
|
||||
$this->path = $this->filestorepath.'/'.$hash;
|
||||
make_writable_directory($this->path);
|
||||
make_writable_directory($this->path, false);
|
||||
if ($this->prescan && $definition->get_mode() !== self::MODE_REQUEST) {
|
||||
$this->prescan = false;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
|
||||
$dir = $this->path . '/' . $subdir;
|
||||
if ($create) {
|
||||
// Create the directory. This function does it recursivily!
|
||||
make_writable_directory($dir);
|
||||
make_writable_directory($dir, false);
|
||||
}
|
||||
return $dir . '/' . $key . '.cache';
|
||||
}
|
||||
|
||||
+9
-4
@@ -1236,10 +1236,15 @@ function make_writable_directory($dir, $exceptiononerror = true) {
|
||||
|
||||
if (!file_exists($dir)) {
|
||||
if (!mkdir($dir, $CFG->directorypermissions, true)) {
|
||||
if ($exceptiononerror) {
|
||||
throw new invalid_dataroot_permissions($dir.' can not be created, check permissions.');
|
||||
} else {
|
||||
return false;
|
||||
clearstatcache();
|
||||
// There might be a race condition when creating directory.
|
||||
if (!is_dir($dir)) {
|
||||
if ($exceptiononerror) {
|
||||
throw new invalid_dataroot_permissions($dir.' can not be created, check permissions.');
|
||||
} else {
|
||||
debugging('Can not create directory: '.$dir, DEBUG_DEVELOPER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user