Merge maintenance-work branch:
[lhc/web/wiklou.git] / maintenance / doMaintenance.php
1 <?php
2 /**
3 * We want to make this whole thing as seamless as possible to the
4 * end-user. Unfortunately, we can't do _all_ of the work in the class
5 * because A) included files are not in global scope, but in the scope
6 * of their caller, and B) MediaWiki has way too many globals. So instead
7 * we'll kinda fake it, and do the requires() inline. <3 PHP
8 */
9
10 if( !isset( $maintClass ) || !class_exists( $maintClass ) ) {
11 echo "\$maintClass is not set or is set to a non-existent class.";
12 die();
13 }
14
15 if( defined( 'MW_NO_SETUP' ) ) {
16 return;
17 }
18
19 // Get an object to start us off
20 $maintenance = new $maintClass();
21
22 // Basic sanity checks and such
23 $maintenance->setup();
24
25 # Setup the profiler
26 if ( file_exists( "$IP/StartProfiler.php" ) ) {
27 require_once( "$IP/StartProfiler.php" );
28 } else {
29 require_once( "$IP/includes/ProfilerStub.php" );
30 }
31
32 // Load settings, using wikimedia-mode if needed
33 if( file_exists( dirname(__FILE__).'/wikimedia-mode' ) ) {
34 # TODO FIXME! Wikimedia-specific stuff needs to go away to an ext
35 # Maybe a hook?
36 global $cluster;
37 $wgWikiFarm = true;
38 $cluster = 'pmtma';
39 require_once( "$IP/includes/AutoLoader.php" );
40 require_once( "$IP/includes/SiteConfiguration.php" );
41 require( "$IP/wgConf.php" );
42 $maintenance->loadWikimediaSettings();
43 require( $IP.'/includes/Defines.php' );
44 require( $IP.'/CommonSettings.php' );
45 } else {
46 require_once( "$IP/includes/AutoLoader.php" );
47 require_once( "$IP/includes/Defines.php" );
48 require_once( $maintenance->loadSettings() );
49 }
50 // Some last includes
51 require_once( "$IP/includes/Setup.php" );
52 require_once( "$IP/install-utils.inc" );
53
54 $wgTitle = null; # Much much faster startup than creating a title object
55
56 try {
57 $maintenance->execute();
58 } catch( MWException $mwe ) {
59 echo( $mwe->getText() );
60 }