From 1f76c475d482c257bffa06ce116a3e03e8f72f52 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Mon, 23 Aug 2010 01:53:31 +0000 Subject: [PATCH] (bug 24898) MediaWiki uses /tmp even if a vHost-specific tempdir is set, also make wfTempDir() return a sane value for Windows on worst-case --- RELEASE-NOTES | 2 ++ includes/GlobalFunctions.php | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fe40782166..081698523f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -301,6 +301,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN revisions" on diffs when appropriate. * (bug 23703) ForeignAPIRepo fails on findBySha1() when using a 1.14 install as a repository due to missing 'name' attribute from the API list=allimages +* (bug 24898) MediaWiki uses /tmp even if a vHost-specific tempdir is set, also + make wfTempDir() return a sane value for Windows on worst-case === API changes in 1.17 === * (bug 22738) Allow filtering by action type on query=logevent. diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 08b8c609a5..e342fd1d3d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2159,10 +2159,10 @@ function &wfGetMimeMagic() { } /** - * Tries to get the system directory for temporary files. For PHP >= 5.2.1, - * we'll use sys_get_temp_dir(). The TMPDIR, TMP, and TEMP environment - * variables are then checked in sequence, and if none are set /tmp is - * returned as the generic Unix default. + * Tries to get the system directory for temporary files. The TMPDIR, TMP, and + * TEMP environment variables are then checked in sequence, and if none are set + * try sys_get_temp_dir() for PHP >= 5.2.1. All else fails, return /tmp for Unix + * or C:\Windows\Temp for Windows and hope for the best. * It is common to call it with tempnam(). * * NOTE: When possible, use instead the tmpfile() function to create @@ -2171,17 +2171,17 @@ function &wfGetMimeMagic() { * @return String */ function wfTempDir() { - if( function_exists( 'sys_get_temp_dir' ) ) { - return sys_get_temp_dir(); - } foreach( array( 'TMPDIR', 'TMP', 'TEMP' ) as $var ) { $tmp = getenv( $var ); if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) { return $tmp; } } + if( function_exists( 'sys_get_temp_dir' ) ) { + return sys_get_temp_dir(); + } # Hope this is Unix of some kind! - return '/tmp'; + return wfIsWindows() ? 'C:\Windows\Temp' : '/tmp'; } /** -- 2.20.1