tempnam accepts a directory as its first parameter, not a full path and filename.

tempnam falls back to creating a file in the system's temp directory. On systems with open_basedir restrictions, this may trigger an error message. By moving this below the checkTemporaryDirectory-loop, tempnam will only be tested if all alternatives fail and the error message is most likely avoided.
This commit is contained in:
Lars 2015-12-24 00:20:30 +01:00 committed by Thomas Müller
parent 05f9b40419
commit 3a5087ccdf
1 changed files with 6 additions and 5 deletions

View File

@ -225,11 +225,6 @@ class TempManager implements ITempManager {
if ($temp = getenv('TMPDIR')) {
$directories[] = $temp;
}
$temp = tempnam(__FILE__, '');
if (file_exists($temp)) {
unlink($temp);
$directories[] = dirname($temp);
}
if ($temp = sys_get_temp_dir()) {
$directories[] = $temp;
}
@ -239,6 +234,12 @@ class TempManager implements ITempManager {
return $dir;
}
}
$temp = tempnam(dirname(__FILE__), '');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
throw new \UnexpectedValueException('Unable to detect system temporary directory');
}