* (bug 25946) The message on the top of Special:RecentChanges is now displayed
in user language instead of content language
* (bug 35264) Wrong type used for <ns> in export.xsd
+* (bug 24985) Use $wgTmpDirectory as the default temp directory so that people
+ who don't have access to /tmp can specify an alternative.
=== API changes in 1.20 ===
* (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API.
* The local filesystem path to a temporary directory. This is not required to
* be web accessible.
*
- * Will default to "{$wgUploadDirectory}/tmp" in Setup.php
+ * When this setting is set to false, its value will be set through a call
+ * to wfTempDir(). See that methods implementation for the actul detection
+ * logic.
+ *
+ * Developers should use the global function wfTempDir() instead of this
+ * variable.
+ *
+ * @see wfTempDir()
+ * @note Default modified to false in v1.20
+ *
*/
$wgTmpDirectory = false;
}
/**
- * 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().
+ * Tries to get the system directory for temporary files. First
+ * $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP
+ * environment variables are then checked in sequence, and if none are
+ * set try sys_get_temp_dir().
*
* NOTE: When possible, use instead the tmpfile() function to create
* temporary files to avoid race conditions on file creation, etc.
* @return String
*/
function wfTempDir() {
- foreach( array( 'TMPDIR', 'TMP', 'TEMP' ) as $var ) {
- $tmp = getenv( $var );
+ global $wgTmpDirectory;
+
+ if ( $wgTmpDirectory !== false ) {
+ return $wgTmpDirectory;
+ }
+
+ $tmpDir = array_map( "getenv", array( 'TMPDIR', 'TMP', 'TEMP' ) );
+
+ foreach( $tmpDir as $tmp ) {
if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
return $tmp;
}
if ( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
if ( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
-
-if ( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
-
if ( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
if ( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
if ( $wgDeletedDirectory === false ) $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
wfProfileOut( $fname . '-includes' );
}
-# Now that GlobalFunctions is loaded, set the default for $wgCanonicalServer
+# Now that GlobalFunctions is loaded, set defaults that depend
+# on it.
+if ( $wgTmpDirectory === false ) {
+ $wgTmpDirectory = wfTempDir();
+}
+
if ( $wgCanonicalServer === false ) {
$wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
}
}
if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
# Diff via the shell
- global $wgTmpDirectory;
- $tempName1 = tempnam( $wgTmpDirectory, 'diff_' );
- $tempName2 = tempnam( $wgTmpDirectory, 'diff_' );
+ $tmpDir = wfTempDir();
+ $tempName1 = tempnam( $tmpDir, 'diff_' );
+ $tempName2 = tempnam( $tmpDir, 'diff_' );
$tempFile1 = fopen( $tempName1, "w" );
if ( !$tempFile1 ) {
/**
* This class is used to hold the location and do limited manipulation
- * of files stored temporarily (usually this will be $wgTmpDirectory)
+ * of files stored temporarily (this will be whatever wfTempDir() returns)
*
* @ingroup FileBackend
*/
* for systems that don't have it.
*
* On construction you can pass array( 'dir' => '/some/path' ); as a parameter
- * to override the default DBA files directory (wgTmpDirectory).
+ * to override the default DBA files directory (wfTempDir()).
*
* @ingroup Cache
*/
global $wgDBAhandler;
if ( !isset( $params['dir'] ) ) {
- global $wgTmpDirectory;
- $params['dir'] = $wgTmpDirectory;
+ $params['dir'] = wfTempDir();
}
$this->mFile = $params['dir']."/mw-cache-" . wfWikiID();
}
function restoreText( $revIds, $xml ) {
- global $wgTmpDirectory, $wgDBname;
+ global $wgDBname;
+ $tmpDir = wfTempDir();
if ( !count( $revIds ) ) {
return;
print "Restoring text from XML backup...\n";
- $revFileName = "$wgTmpDirectory/broken-revlist-$wgDBname";
- $filteredXmlFileName = "$wgTmpDirectory/filtered-$wgDBname.xml";
+ $revFileName = "$tmpDir/broken-revlist-$wgDBname";
+ $filteredXmlFileName = "$tmpDir/filtered-$wgDBname.xml";
// Write revision list
if ( !file_put_contents( $revFileName, implode( "\n", $revIds ) ) ) {
$this->errors['fixed'][$id] = true;
}
}
-