revisions only or complete histories.
* (bug 2150) Fix tab indexes on edit form
* (bug 2152) Add missing bgcolor to attribute whitelist for <td> and <th>
+* Group table renamed.....?
+* (bug 2178) Use temp dir from environment in parser tests
=== Caveats ===
}
# Make temporary files
- $td = '/tmp/';
+ $td = wfTempDir();
$oldtextFile = fopen( $oldtextName = tempnam( $td, 'merge-old-' ), 'w' );
$mytextFile = fopen( $mytextName = tempnam( $td, 'merge-mine-' ), 'w' );
$yourtextFile = fopen( $yourtextName = tempnam( $td, 'merge-your-' ), 'w' );
return wfElement( $element, $attribs, UtfNormal::cleanUp( $contents ) );
}
+/**
+ * Tries to get the system directory for temporary files.
+ * The TMPDIR, TMP, and TEMP environment variables are checked in sequence,
+ * and if none are set /tmp is returned as the generic Unix default.
+ *
+ * NOTE: When possible, use the tempfile() 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( 'TMPDIR' );
+ if( $tmp && file_exists( $tmp ) && is_dir( $tmp ) && is_writable( $tmp ) ) {
+ return $tmp;
+ }
+ }
+ # Hope this is Unix of some kind!
+ return '/tmp';
+}
+
?>
$html2xml = implode('/', $a);
$a = array ();
- $tmpfname = tempnam('/tmp', 'FOO');
+ $tmpfname = tempnam( wfTempDir(), 'FOO' );
$handle = fopen($tmpfname, 'w');
fwrite($handle, utf8_encode($text));
fclose($handle);
$this->html2xml($text);
- $tmpfname = tempnam('/tmp', 'FOO');
+ $tmpfname = tempnam( wfTempDir(), 'FOO');
$handle = fopen($tmpfname, 'w');
fwrite($handle, $text);
fclose($handle);
'wgDBprefix' => 'parsertest',
'wgDefaultUserOptions' => array(),
- 'wgLoadBalancer' => LoadBalancer::newFromParams( $GLOBALS['wgDBservers'] ),
'wgLang' => new LanguageUtf8(),
'wgContLang' => new LanguageUtf8(),
'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)),
# Make sure we don't mess with the live DB
if (!$setupDB && $wgDBprefix === 'parsertest') {
+ # oh teh horror
+ $GLOBALS['wgLoadBalancer'] = LoadBalancer::newFromParams( $GLOBALS['wgDBservers'] );
$db =& wfGetDB( DB_MASTER );
$tables = $this->listTables();
function setupUploadDir() {
global $IP;
- $dir = "/tmp/mwParser-" . mt_rand() . "-images";
+ $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
mkdir( $dir );
mkdir( $dir . '/3' );
mkdir( $dir . '/3/3a' );
* @access private
*/
function quickDiff( $input, $output ) {
- $prefix = "/tmp/mwParser-" . mt_rand();
+ $prefix = wfTempDir() . "/mwParser-" . mt_rand();
$infile = "$prefix-expected";
$this->dumpToFile( $input, $infile );
$this->save[$var] = $GLOBALS[$var];
}
}
- $GLOBALS['wgReadOnlyFile'] = '/tmp/testReadOnly-' . mt_rand();
+ $GLOBALS['wgReadOnlyFile'] = wfTempDir() . '/testReadOnly-' . mt_rand();
}
function tearDown() {