r71457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71456‎ | r71457 | r71458 >
Date:01:53, 23 August 2010
Author:demon
Status:ok (Comments)
Tags:
Comment:
(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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2159,10 +2159,10 @@
21602160 }
21612161
21622162 /**
2163 - * Tries to get the system directory for temporary files. For PHP >= 5.2.1,
2164 - * we'll use sys_get_temp_dir(). The TMPDIR, TMP, and TEMP environment
2165 - * variables are then checked in sequence, and if none are set /tmp is
2166 - * returned as the generic Unix default.
 2163+ * Tries to get the system directory for temporary files. The TMPDIR, TMP, and
 2164+ * TEMP environment variables are then checked in sequence, and if none are set
 2165+ * try sys_get_temp_dir() for PHP >= 5.2.1. All else fails, return /tmp for Unix
 2166+ * or C:\Windows\Temp for Windows and hope for the best.
21672167 * It is common to call it with tempnam().
21682168 *
21692169 * NOTE: When possible, use instead the tmpfile() function to create
@@ -2171,17 +2171,17 @@
21722172 * @return String
21732173 */
21742174 function wfTempDir() {
2175 - if( function_exists( 'sys_get_temp_dir' ) ) {
2176 - return sys_get_temp_dir();
2177 - }
21782175 foreach( array( 'TMPDIR', 'TMP', 'TEMP' ) as $var ) {
21792176 $tmp = getenv( $var );
21802177 if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
21812178 return $tmp;
21822179 }
21832180 }
 2181+ if( function_exists( 'sys_get_temp_dir' ) ) {
 2182+ return sys_get_temp_dir();
 2183+ }
21842184 # Hope this is Unix of some kind!
2185 - return '/tmp';
 2185+ return wfIsWindows() ? 'C:\Windows\Temp' : '/tmp';
21862186 }
21872187
21882188 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -301,6 +301,8 @@
302302 revisions" on diffs when appropriate.
303303 * (bug 23703) ForeignAPIRepo fails on findBySha1() when using a 1.14 install as
304304 a repository due to missing 'name' attribute from the API list=allimages
 305+* (bug 24898) MediaWiki uses /tmp even if a vHost-specific tempdir is set, also
 306+ make wfTempDir() return a sane value for Windows on worst-case
305307
306308 === API changes in 1.17 ===
307309 * (bug 22738) Allow filtering by action type on query=logevent.

Comments

#Comment by 😂 (talk | contribs)   01:54, 23 August 2010

This is a regression. Probably worth backporting to REL1_16.

#Comment by Platonides (talk | contribs)   11:43, 23 August 2010

If the issue is that the vhost has a upload_tmp_dir set and sys_get_temp_dir doesn't account for that, shouldn't you be using ini_get('upload_tmp_dir') if it's not empty?

#Comment by Simetrical (talk | contribs)   21:51, 26 August 2010

The bug had someone using "SetEnv TMP /home/www/example.com/tmp/". Is that standard? Should we tell them to do it in some better way?

#Comment by 😂 (talk | contribs)   16:25, 30 August 2010

Maybe, maybe not. In any case, wfTempDir() had worked for quite some time before I added sys_get_temp_dir(), so relying on TMPDIR, TMP, TEMP has been acceptable it would seem.

#Comment by 😂 (talk | contribs)   16:23, 30 August 2010

Assuming what we're doing is an upload. Or would it be generally sane just to throw any temp file into upload_tmp_dir?

Status & tagging log