r70009 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70008‎ | r70009 | r70010 >
Date:12:30, 27 July 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Use MediaWiki wfTempDir() and tempnam() instead of global $tmpPath and rand()
Modified paths:
  • /trunk/phase3/maintenance/mwdocgen.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/mwdocgen.php
@@ -37,9 +37,6 @@
3838 /** Figure out the base directory for MediaWiki location */
3939 $mwPath = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR;
4040
41 -/** Global variable: temporary directory */
42 -$tmpPath = '/tmp/';
43 -
4441 /** doxygen binary script */
4542 $doxygenBin = 'doxygen';
4643
@@ -67,6 +64,9 @@
6865 # Functions
6966 #
7067
 68+define( 'MEDIAWIKI', true );
 69+require_once( "$mwPath/includes/GlobalFunctions.php" );
 70+
7171 /**
7272 * Read a line from the shell
7373 * @param $prompt String
@@ -133,7 +133,6 @@
134134 * (LocalSettings.php, AdminSettings.php and .svn directories are always excluded)
135135 */
136136 function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude ) {
137 - global $tmpPath;
138137
139138 $template = file_get_contents( $doxygenTemplate );
140139
@@ -147,7 +146,7 @@
148147 '{{EXCLUDE}}' => $exclude,
149148 );
150149 $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template );
151 - $tmpFileName = $tmpPath . 'mwdocgen' . rand() . '.tmp';
 150+ $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' );
152151 file_put_contents( $tmpFileName , $tmpCfg ) or die( "Could not write doxygen configuration to file $tmpFileName\n" );
153152
154153 return $tmpFileName;

Comments

#Comment by Hashar (talk | contribs)   12:24, 6 November 2010

thanks!

#Comment by Platonides (talk | contribs)   15:07, 6 November 2010

No problem :)

Status & tagging log