r109711 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109710‎ | r109711 | r109712 >
Date:01:00, 22 January 2012
Author:reedy
Status:reverted (Comments)
Tags:tools 
Comment:
* (bug 33284) Make mwscript.php also look in WikimediaMaintenance
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWScript.php (modified) (history)
  • /trunk/tools/mwmultiversion/multiversion/MWVersion.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/MWScript.php
@@ -23,12 +23,6 @@
2424 die( "The MediaWiki script file path must be the first argument.\n" );
2525 }
2626
27 - $relFile = $argv[1]; // the script file to run
28 - # If no MW directory is given then assume this is a /maintenance script
29 - if ( strpos( $relFile, '/' ) === false ) {
30 - $relFile = "maintenance/$relFile"; // convenience
31 - }
32 -
3327 # Remove effects of this wrapper from $argv...
3428 array_shift( $argv ); // remove this file's name from args
3529 # Code stolen from wfBasename() in GlobalFunctions.php :)
@@ -50,22 +44,36 @@
5145 'extensions/WikimediaMaintenance/rebuildInterwiki.php' // 1.19
5246 );
5347
 48+ # MWScript.php should be in common/
 49+ require_once( dirname( __FILE__ ) . '/MWVersion.php' );
 50+
 51+ $relFile = $argv[0];
 52+
 53+ if ( strpos( $relFile, '/' ) === false ) {
 54+ // If no MW directory is given then assume this is either
 55+ // a /maintenance or an extensions/WikimediaMaintenance/
 56+ // script
 57+ $file = getMediaWikiCli( "maintenance/$relFile" );
 58+ if ( !file_exists( $file ) ) {
 59+ $file = getMediaWikiCli( "extensions/WikimediaMaintenance/$relFile" );
 60+ }
 61+ } else {
 62+ $file = getMediaWikiCli( $relFile );
 63+ }
 64+
 65+ if ( !file_exists( $file ) ) {
 66+ die( "The MediaWiki script file \"{$file}\" does not exist.\n" );
 67+ }
 68+
5469 # Check if a --wiki param was given...
5570 # Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-'
5671 if ( !isset( $argv[1] ) || !preg_match( '/^([^-]|--wiki(=|$))/', $argv[1] ) ) {
5772 if ( in_array( $relFile, $wikiless ) ) {
58 - # Assumme aawiki as Maintenance.php does.
 73+ # Assume aawiki as Maintenance.php does.
5974 $argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) );
6075 }
6176 }
6277
63 - # MWScript.php should be in common/
64 - require_once( dirname( __FILE__ ) . '/MWVersion.php' );
65 - $file = getMediaWikiCli( $relFile );
66 - if ( !file_exists( $file ) ) {
67 - die( "The MediaWiki script file \"{$file}\" does not exist.\n" );
68 - }
69 -
7078 return $file;
7179 }
7280
Index: trunk/tools/mwmultiversion/multiversion/MWVersion.php
@@ -17,7 +17,7 @@
1818 */
1919 function getMediaWiki( $file ) {
2020 global $IP;
21 - require( dirname( __FILE__ ) . '/MWMultiVersion.php' );
 21+ require_once( dirname( __FILE__ ) . '/MWMultiVersion.php' );
2222
2323 $scriptName = @$_SERVER['SCRIPT_NAME'];
2424 $serverName = @$_SERVER['SERVER_NAME'];
@@ -78,8 +78,11 @@
7979 function getMediaWikiCli( $file ) {
8080 global $IP;
8181
82 - require( dirname( __FILE__ ) . '/MWMultiVersion.php' );
83 - $multiVersion = MWMultiVersion::initializeForMaintenance();
 82+ static $multiVersion = null;
 83+ if( !$multiVersion ) {
 84+ require_once( dirname( __FILE__ ) . '/MWMultiVersion.php' );
 85+ $multiVersion = MWMultiVersion::initializeForMaintenance();
 86+ }
8487 if ( $multiVersion->getDatabase() === 'testwiki' ) {
8588 define( 'TESTWIKI', 1 );
8689 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r109731Fix first part of fixme from r109711, getting rid of the static variablereedy13:47, 22 January 2012
r109739Followup r109711...reedy15:13, 22 January 2012
r109825Reverting out changes to MWScript.php from r109711, r109739...reedy14:52, 23 January 2012

Comments

#Comment by Aaron Schulz (talk | contribs)   02:49, 22 January 2012

Please kill the ugly MWVersion.php static var. Just always require_once MWMultiVersion and check MWMultiVersion::getInstance(). This also seems to have broken $wikiLess script checking.

Status & tagging log