r109739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109738‎ | r109739 | r109740 >
Date:15:13, 22 January 2012
Author:reedy
Status:reverted (Comments)
Tags:tools 
Comment:
Followup r109711

When given a script, it may or may not have the full path. So cannot do a direct array comparison. Which means it can be: $relFile, $maintenance . $relFile, $wikimediaMaintenance . $relFile

Try all locations, and if no matches to the wikiless presume it needs a wiki parameter (or else, it's a script we haven't been told is wikiless yet, tough! add it yourself)

The scripts that have moved for 1.19 can be removed from the phase3/maintenance $wikiless list after 1.19 is sitewide
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWScript.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/MWScript.php
@@ -30,32 +30,48 @@
3131 $argv[0] = $matches[1]; // make first arg the script file name
3232 }
3333
 34+ $maintenance = "maintenance/";
 35+ $wikimediaMaintenance = "extensions/WikimediaMaintenance/";
3436 # For addwiki.php, the wiki DB doesn't yet exist, and for some
3537 # other maintenance scripts we don't care what wiki DB is used...
3638 $wikiless = array(
37 - 'maintenance/mctest.php',
38 - 'maintenance/addwiki.php',
39 - 'maintenance/nextJobDB.php',
40 - 'maintenance/dumpInterwiki.php',
41 - 'maintenance/rebuildInterwiki.php',
42 - 'extensions/WikimediaMaintenance/addWiki.php', // 1.19
43 - 'extensions/WikimediaMaintenance/dumpInterwiki.php', // 1.19
44 - 'extensions/WikimediaMaintenance/getJobQueueLengths.php',
45 - 'extensions/WikimediaMaintenance/rebuildInterwiki.php' // 1.19
 39+ $maintenance . 'mctest.php',
 40+ $maintenance . 'addwiki.php',
 41+ $maintenance . 'nextJobDB.php',
 42+ $maintenance . 'dumpInterwiki.php',
 43+ $maintenance . 'rebuildInterwiki.php',
 44+ $wikimediaMaintenance . 'addWiki.php', // 1.19
 45+ $wikimediaMaintenance . 'dumpInterwiki.php', // 1.19
 46+ $wikimediaMaintenance . 'getJobQueueLengths.php',
 47+ $wikimediaMaintenance . 'rebuildInterwiki.php' // 1.19
4648 );
4749
 50+ $relFile = $argv[0];
 51+
 52+ # Check if a --wiki param was given...
 53+ # Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-'
 54+ if ( !isset( $argv[1] ) || !preg_match( '/^([^-]|--wiki(=|$))/', $argv[1] ) ) {
 55+ // All the possible locations of a wikiless script
 56+ $possibles = array( $relFile, $maintenance . $relFile, $wikimediaMaintenance . $relFile );
 57+ foreach( $possibles as $poss ) {
 58+ if ( in_array( $poss, $wikiless ) ) {
 59+ # Assume aawiki as Maintenance.php does.
 60+ $argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) );
 61+ break;
 62+ }
 63+ }
 64+ }
 65+
4866 # MWScript.php should be in common/
4967 require_once( dirname( __FILE__ ) . '/MWVersion.php' );
5068
51 - $relFile = $argv[0];
52 -
5369 if ( strpos( $relFile, '/' ) === false ) {
5470 // If no MW directory is given then assume this is either
5571 // a /maintenance or an extensions/WikimediaMaintenance/
5672 // script
57 - $file = getMediaWikiCli( "maintenance/$relFile" );
 73+ $file = getMediaWikiCli( $maintenance . $relFile );
5874 if ( !file_exists( $file ) ) {
59 - $file = getMediaWikiCli( "extensions/WikimediaMaintenance/$relFile" );
 75+ $file = getMediaWikiCli( $wikimediaMaintenance . $relFile );
6076 }
6177 } else {
6278 $file = getMediaWikiCli( $relFile );
@@ -65,15 +81,6 @@
6682 die( "The MediaWiki script file \"{$file}\" does not exist.\n" );
6783 }
6884
69 - # Check if a --wiki param was given...
70 - # Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-'
71 - if ( !isset( $argv[1] ) || !preg_match( '/^([^-]|--wiki(=|$))/', $argv[1] ) ) {
72 - if ( in_array( $relFile, $wikiless ) ) {
73 - # Assume aawiki as Maintenance.php does.
74 - $argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) );
75 - }
76 - }
77 -
7885 return $file;
7986 }
8087

Follow-up revisions

RevisionCommit summaryAuthorDate
r109825Reverting out changes to MWScript.php from r109711, r109739...reedy14:52, 23 January 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109711* (bug 33284) Make mwscript.php also look in WikimediaMaintenancereedy01:00, 22 January 2012

Comments

#Comment by Aaron Schulz (talk | contribs)   04:28, 23 January 2012

You do "$argv[0] = $matches[1]; // make first arg the script file name" before ever storing the original. Things like "mwscript extensions/FlaggedRevs/maintenance/FILE" won't work with this since it will do getMediaWikiCli( "FILE" ).

#Comment by Reedy (talk | contribs)   14:48, 23 January 2012

Re-educating users to give the full path (though, that is what they are more traditionally used to) would be so much easier ;)

I'm gonna revert out most of this for the moment, until I get more time to actually work on it. Reduces the chance of accidentally getting partially broken versions live on WMF

#Comment by Aaron Schulz (talk | contribs)   04:29, 23 January 2012

Also, be sure to read my BZ comment :)

#Comment by Reedy (talk | contribs)   14:12, 23 January 2012
+	$relFile = $argv[0];
+
+	# Check if a --wiki param was given...
+	# Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-'
+	if ( !isset( $argv[1] ) || !preg_match( '/^([^-]|--wiki(=|$))/', $argv[1] ) ) {
+		// All the possible locations of a wikiless script
+		$possibles = array( $relFile, $maintenance . $relFile, $wikimediaMaintenance . $relFile );
+		foreach( $possibles as $poss ) {
+			if ( in_array( $poss, $wikiless ) ) {
+				# Assume aawiki as Maintenance.php does.
+				$argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) );
+				break;
+			}
+		}
+	}

$argv[0] is pulled off before the array is overwritten

#Comment by Reedy (talk | contribs)   14:17, 23 January 2012

Oh..

Status & tagging log