Index: trunk/tools/mwmultiversion/multiversion/MWScript.php |
— | — | @@ -23,6 +23,12 @@ |
24 | 24 | die( "The MediaWiki script file path must be the first argument.\n" ); |
25 | 25 | } |
26 | 26 | |
| 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 | + |
27 | 33 | # Remove effects of this wrapper from $argv... |
28 | 34 | array_shift( $argv ); // remove this file's name from args |
29 | 35 | # Code stolen from wfBasename() in GlobalFunctions.php :) |
— | — | @@ -30,54 +36,33 @@ |
31 | 37 | $argv[0] = $matches[1]; // make first arg the script file name |
32 | 38 | } |
33 | 39 | |
34 | | - $maintenance = "maintenance/"; |
35 | | - $wikimediaMaintenance = "extensions/WikimediaMaintenance/"; |
36 | 40 | # For addwiki.php, the wiki DB doesn't yet exist, and for some |
37 | 41 | # other maintenance scripts we don't care what wiki DB is used... |
38 | 42 | $wikiless = array( |
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 |
| 43 | + 'maintenance/mctest.php', |
| 44 | + 'maintenance/addwiki.php', |
| 45 | + 'maintenance/nextJobDB.php', |
| 46 | + 'maintenance/dumpInterwiki.php', |
| 47 | + 'maintenance/rebuildInterwiki.php', |
| 48 | + 'extensions/WikimediaMaintenance/addWiki.php', // 1.19 |
| 49 | + 'extensions/WikimediaMaintenance/dumpInterwiki.php', // 1.19 |
| 50 | + 'extensions/WikimediaMaintenance/getJobQueueLengths.php', |
| 51 | + 'extensions/WikimediaMaintenance/rebuildInterwiki.php' // 1.19 |
48 | 52 | ); |
49 | 53 | |
50 | | - $relFile = $argv[0]; |
51 | | - |
52 | 54 | # Check if a --wiki param was given... |
53 | 55 | # Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-' |
54 | 56 | 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 | | - } |
| 57 | + if ( in_array( $relFile, $wikiless ) ) { |
| 58 | + # Assumme aawiki as Maintenance.php does. |
| 59 | + $argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) ); |
63 | 60 | } |
64 | 61 | } |
65 | 62 | |
66 | 63 | # MWScript.php should be in common/ |
67 | 64 | require_once( dirname( __FILE__ ) . '/MWVersion.php' ); |
68 | | - |
69 | | - if ( strpos( $relFile, '/' ) === false ) { |
70 | | - // If no MW directory is given then assume this is either |
71 | | - // a /maintenance or an extensions/WikimediaMaintenance/ |
72 | | - // script |
73 | | - $file = getMediaWikiCli( $maintenance . $relFile ); |
74 | | - if ( !file_exists( $file ) ) { |
75 | | - $file = getMediaWikiCli( $wikimediaMaintenance . $relFile ); |
76 | | - } |
77 | | - } else { |
78 | | - $file = getMediaWikiCli( $relFile ); |
79 | | - } |
80 | | - |
81 | | - if ( !file_exists( $file ) ) { |
| 65 | + $file = getMediaWikiCli( $relFile ); |
| 66 | + if ( !file_exists( $file ) ) { |
82 | 67 | die( "The MediaWiki script file \"{$file}\" does not exist.\n" ); |
83 | 68 | } |
84 | 69 | |