r61698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61697‎ | r61698 | r61699 >
Date:23:52, 29 January 2010
Author:demon
Status:ok
Tags:
Comment:
Followup r61655, add sys_get_temp_dir() support to wfTempDir(), use this in HttpTest rather than duplicating code
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/tests/HttpTest.php (modified) (history)
  • /trunk/phase3/tests/bootstrap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/bootstrap.php
@@ -21,18 +21,4 @@
2222 require_once "$IP/includes/GlobalFunctions.php";
2323 require_once "$IP/includes/Hooks.php";
2424
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 - }
3925
Index: trunk/phase3/tests/HttpTest.php
@@ -32,8 +32,8 @@
3333 $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.");
3434 }
3535
36 - $content = tempnam( sys_get_temp_dir(), "" );
37 - $headers = tempnam( sys_get_temp_dir(), "" );
 36+ $content = tempnam( wfTempDir(), "" );
 37+ $headers = tempnam( wfTempDir(), "" );
3838 if ( !$content && !$headers ) {
3939 die( "Couldn't create temp file!" );
4040 }
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2135,9 +2135,10 @@
21362136 }
21372137
21382138 /**
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.
21422143 *
21432144 * NOTE: When possible, use the tempfile() function to create temporary
21442145 * files to avoid race conditions on file creation, etc.
@@ -2145,6 +2146,9 @@
21462147 * @return String
21472148 */
21482149 function wfTempDir() {
 2150+ if( function_exists( 'sys_get_temp_dir' ) ) {
 2151+ return sys_get_temp_dir();
 2152+ }
21492153 foreach( array( 'TMPDIR', 'TMP', 'TEMP' ) as $var ) {
21502154 $tmp = getenv( $var );
21512155 if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61655follow up r61357...mah07:25, 29 January 2010

Status & tagging log