Issue #3036494 by Berdir, alexpott, rgpublic, cilefen, kerasai, regilero: Race condition in ImageStyle::createDerivative()

merge-requests/172/head
catch 2020-12-18 09:45:37 +00:00
parent f6bde5471f
commit f9fcde32ab
1 changed files with 13 additions and 3 deletions

View File

@ -520,12 +520,22 @@ class FileSystem implements FileSystemInterface {
}
if (!is_dir($directory)) {
if (!($options & static::CREATE_DIRECTORY)) {
return FALSE;
}
// Let mkdir() recursively create directories and use the default
// directory permissions.
if ($options & static::CREATE_DIRECTORY) {
return @$this->mkdir($directory, NULL, TRUE);
$success = @$this->mkdir($directory, NULL, TRUE);
if ($success) {
return TRUE;
}
// If the operation failed, check again if the directory was created
// by another process/server, only report a failure if not. In this case
// we still need to ensure the directory is writable.
if (!is_dir($directory)) {
return FALSE;
}
return FALSE;
}
$writable = is_writable($directory);