From 3a5087ccdff79012a6c14adb63dbaa2e61607f2d Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 24 Dec 2015 00:20:30 +0100 Subject: [PATCH] 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. --- lib/private/tempmanager.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/private/tempmanager.php b/lib/private/tempmanager.php index c4fa9231eb..ae7b9c98e3 100644 --- a/lib/private/tempmanager.php +++ b/lib/private/tempmanager.php @@ -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'); }