mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: Better error checking for non-writable temp paths
Fixes https://github.com/silverstripe/silverstripe-framework/issues/1666
This commit is contained in:
parent
93e92e49c5
commit
09164e7e2a
@ -60,8 +60,6 @@ function getTempParentFolder($base = null)
|
|||||||
$base = BASE_PATH;
|
$base = BASE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
$worked = true;
|
|
||||||
|
|
||||||
// first, try finding a silverstripe-cache dir built off the base path
|
// first, try finding a silverstripe-cache dir built off the base path
|
||||||
$tempPath = $base . DIRECTORY_SEPARATOR . 'silverstripe-cache';
|
$tempPath = $base . DIRECTORY_SEPARATOR . 'silverstripe-cache';
|
||||||
if (@file_exists($tempPath)) {
|
if (@file_exists($tempPath)) {
|
||||||
@ -77,7 +75,7 @@ function getTempParentFolder($base = null)
|
|||||||
str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
str_replace(array(' ', '/', ':', '\\'), '-', $base);
|
||||||
if (!@file_exists($tempPath)) {
|
if (!@file_exists($tempPath)) {
|
||||||
$oldUMask = umask(0);
|
$oldUMask = umask(0);
|
||||||
$worked = @mkdir($tempPath, 0777);
|
@mkdir($tempPath, 0777);
|
||||||
umask($oldUMask);
|
umask($oldUMask);
|
||||||
|
|
||||||
// if the folder already exists, correct perms
|
// if the folder already exists, correct perms
|
||||||
@ -87,15 +85,18 @@ function getTempParentFolder($base = null)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$worked = @file_exists($tempPath) && @is_writable($tempPath);
|
||||||
|
|
||||||
// failing to use the system path, attempt to create a local silverstripe-cache dir
|
// failing to use the system path, attempt to create a local silverstripe-cache dir
|
||||||
if (!$worked) {
|
if (!$worked) {
|
||||||
$worked = true;
|
|
||||||
$tempPath = $base . DIRECTORY_SEPARATOR . 'silverstripe-cache';
|
$tempPath = $base . DIRECTORY_SEPARATOR . 'silverstripe-cache';
|
||||||
if (!@file_exists($tempPath)) {
|
if (!@file_exists($tempPath)) {
|
||||||
$oldUMask = umask(0);
|
$oldUMask = umask(0);
|
||||||
$worked = @mkdir($tempPath, 0777);
|
@mkdir($tempPath, 0777);
|
||||||
umask($oldUMask);
|
umask($oldUMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$worked = @file_exists($tempPath) && @is_writable($tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$worked) {
|
if (!$worked) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user