Index: trunk/phase3/tests/bootstrap.php |
— | — | @@ -21,18 +21,4 @@ |
22 | 22 | require_once "$IP/includes/GlobalFunctions.php"; |
23 | 23 | require_once "$IP/includes/Hooks.php"; |
24 | 24 | |
25 | | -// for php versions before 5.2.1 |
26 | | -if ( !function_exists('sys_get_temp_dir')) { |
27 | | - function sys_get_temp_dir() { |
28 | | - if( $temp=getenv('TMP') ) return $temp; |
29 | | - if( $temp=getenv('TEMP') ) return $temp; |
30 | | - if( $temp=getenv('TMPDIR') ) return $temp; |
31 | | - $temp=tempnam(__FILE__,''); |
32 | | - if (file_exists($temp)) { |
33 | | - unlink($temp); |
34 | | - return dirname($temp); |
35 | | - } |
36 | | - return null; |
37 | | - } |
38 | | - } |
39 | 25 | |
Index: trunk/phase3/tests/HttpTest.php |
— | — | @@ -32,8 +32,8 @@ |
33 | 33 | $this->markTestIncomplete("This test requires the curl binary at /usr/bin/curl. If you have curl, please file a bug on this test, or, better yet, provide a patch."); |
34 | 34 | } |
35 | 35 | |
36 | | - $content = tempnam( sys_get_temp_dir(), "" ); |
37 | | - $headers = tempnam( sys_get_temp_dir(), "" ); |
| 36 | + $content = tempnam( wfTempDir(), "" ); |
| 37 | + $headers = tempnam( wfTempDir(), "" ); |
38 | 38 | if ( !$content && !$headers ) { |
39 | 39 | die( "Couldn't create temp file!" ); |
40 | 40 | } |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2135,9 +2135,10 @@ |
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | /** |
2139 | | - * Tries to get the system directory for temporary files. |
2140 | | - * The TMPDIR, TMP, and TEMP environment variables are checked in sequence, |
2141 | | - * and if none are set /tmp is returned as the generic Unix default. |
| 2139 | + * Tries to get the system directory for temporary files. For PHP >= 5.2.1, |
| 2140 | + * we'll use sys_get_temp_dir(). The TMPDIR, TMP, and TEMP environment |
| 2141 | + * variables are then checked in sequence, and if none are set /tmp is |
| 2142 | + * returned as the generic Unix default. |
2142 | 2143 | * |
2143 | 2144 | * NOTE: When possible, use the tempfile() function to create temporary |
2144 | 2145 | * files to avoid race conditions on file creation, etc. |
— | — | @@ -2145,6 +2146,9 @@ |
2146 | 2147 | * @return String |
2147 | 2148 | */ |
2148 | 2149 | function wfTempDir() { |
| 2150 | + if( function_exists( 'sys_get_temp_dir' ) ) { |
| 2151 | + return sys_get_temp_dir(); |
| 2152 | + } |
2149 | 2153 | foreach( array( 'TMPDIR', 'TMP', 'TEMP' ) as $var ) { |
2150 | 2154 | $tmp = getenv( $var ); |
2151 | 2155 | if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) { |