MDL-40891 work around make_writable_directory() race condition
You will still get a "PHP Warning: mkdir(): File exists" but that should not cause any problems on production sites.
This commit is contained in:
+9
-4
@@ -1260,10 +1260,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