Index: trunk/tools/mwmultiversion/multiversion/MWScript.php |
— | — | @@ -23,12 +23,6 @@ |
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 | | - |
33 | 27 | # Remove effects of this wrapper from $argv... |
34 | 28 | array_shift( $argv ); // remove this file's name from args |
35 | 29 | # Code stolen from wfBasename() in GlobalFunctions.php :) |
— | — | @@ -50,22 +44,36 @@ |
51 | 45 | 'extensions/WikimediaMaintenance/rebuildInterwiki.php' // 1.19 |
52 | 46 | ); |
53 | 47 | |
| 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 | + |
54 | 69 | # Check if a --wiki param was given... |
55 | 70 | # Maintenance.php will treat $argv[1] as the wiki if it doesn't start '-' |
56 | 71 | if ( !isset( $argv[1] ) || !preg_match( '/^([^-]|--wiki(=|$))/', $argv[1] ) ) { |
57 | 72 | if ( in_array( $relFile, $wikiless ) ) { |
58 | | - # Assumme aawiki as Maintenance.php does. |
| 73 | + # Assume aawiki as Maintenance.php does. |
59 | 74 | $argv = array_merge( array( $argv[0], "--wiki=aawiki" ), array_slice( $argv, 1 ) ); |
60 | 75 | } |
61 | 76 | } |
62 | 77 | |
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 | | - |
70 | 78 | return $file; |
71 | 79 | } |
72 | 80 | |
Index: trunk/tools/mwmultiversion/multiversion/MWVersion.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | */ |
19 | 19 | function getMediaWiki( $file ) { |
20 | 20 | global $IP; |
21 | | - require( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
| 21 | + require_once( dirname( __FILE__ ) . '/MWMultiVersion.php' ); |
22 | 22 | |
23 | 23 | $scriptName = @$_SERVER['SCRIPT_NAME']; |
24 | 24 | $serverName = @$_SERVER['SERVER_NAME']; |
— | — | @@ -78,8 +78,11 @@ |
79 | 79 | function getMediaWikiCli( $file ) { |
80 | 80 | global $IP; |
81 | 81 | |
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 | + } |
84 | 87 | if ( $multiVersion->getDatabase() === 'testwiki' ) { |
85 | 88 | define( 'TESTWIKI', 1 ); |
86 | 89 | } |