Index: trunk/tools/mwmultiversion/multiversion/MWScript.php |
— | — | @@ -30,32 +30,48 @@ |
31 | 31 | $argv[0] = $matches[1]; // make first arg the script file name |
32 | 32 | } |
33 | 33 | |
| 34 | + $maintenance = "maintenance/"; |
| 35 | + $wikimediaMaintenance = "extensions/WikimediaMaintenance/"; |
34 | 36 | # For addwiki.php, the wiki DB doesn't yet exist, and for some |
35 | 37 | # other maintenance scripts we don't care what wiki DB is used... |
36 | 38 | $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 |
46 | 48 | ); |
47 | 49 | |
| 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 | + |
48 | 66 | # MWScript.php should be in common/ |
49 | 67 | require_once( dirname( __FILE__ ) . '/MWVersion.php' ); |
50 | 68 | |
51 | | - $relFile = $argv[0]; |
52 | | - |
53 | 69 | if ( strpos( $relFile, '/' ) === false ) { |
54 | 70 | // If no MW directory is given then assume this is either |
55 | 71 | // a /maintenance or an extensions/WikimediaMaintenance/ |
56 | 72 | // script |
57 | | - $file = getMediaWikiCli( "maintenance/$relFile" ); |
| 73 | + $file = getMediaWikiCli( $maintenance . $relFile ); |
58 | 74 | if ( !file_exists( $file ) ) { |
59 | | - $file = getMediaWikiCli( "extensions/WikimediaMaintenance/$relFile" ); |
| 75 | + $file = getMediaWikiCli( $wikimediaMaintenance . $relFile ); |
60 | 76 | } |
61 | 77 | } else { |
62 | 78 | $file = getMediaWikiCli( $relFile ); |
— | — | @@ -65,15 +81,6 @@ |
66 | 82 | die( "The MediaWiki script file \"{$file}\" does not exist.\n" ); |
67 | 83 | } |
68 | 84 | |
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 | | - |
78 | 85 | return $file; |
79 | 86 | } |
80 | 87 | |