(bug 24898) MediaWiki uses /tmp even if a vHost-specific tempdir is set, also make...
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 23 Aug 2010 01:53:31 +0000 (01:53 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 23 Aug 2010 01:53:31 +0000 (01:53 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php

index fe40782..0816985 100644 (file)
@@ -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.
index 08b8c60..e342fd1 100644 (file)
@@ -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';
 }
 
 /**