Use MediaWiki wfTempDir() and tempnam() instead of global $tmpPath and rand()
authorPlatonides <platonides@users.mediawiki.org>
Tue, 27 Jul 2010 12:30:19 +0000 (12:30 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 27 Jul 2010 12:30:19 +0000 (12:30 +0000)
maintenance/mwdocgen.php

index 05fbdf9..70e9d96 100644 (file)
@@ -37,9 +37,6 @@ if ( php_sapi_name() != 'cli' ) {
 /** Figure out the base directory for MediaWiki location */
 $mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
 
-/** Global variable: temporary directory */
-$tmpPath = '/tmp/';
-
 /** doxygen binary script */
 $doxygenBin = 'doxygen';
 
@@ -67,6 +64,9 @@ $exclude = '';
 # Functions
 #
 
+define( 'MEDIAWIKI', true );
+require_once( "$mwPath/includes/GlobalFunctions.php" );
+
 /**
  * Read a line from the shell
  * @param $prompt String
@@ -133,7 +133,6 @@ function getSvnRevision( $dir ) {
  *                 (LocalSettings.php, AdminSettings.php and .svn directories are always excluded)
  */
 function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude ) {
-       global $tmpPath;
 
        $template = file_get_contents( $doxygenTemplate );
 
@@ -147,7 +146,7 @@ function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath,
                '{{EXCLUDE}}'          => $exclude,
        );
        $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template );
-       $tmpFileName = $tmpPath . 'mwdocgen' . rand() . '.tmp';
+       $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' );
        file_put_contents( $tmpFileName , $tmpCfg ) or die( "Could not write doxygen configuration to file $tmpFileName\n" );
 
        return $tmpFileName;