Merge maintenance-work branch (now with less errors!):
[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 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @author Chad Horohoe <chad@anyonecanedit.org>
25 * @file
26 * @ingroup Maintenance
27 */
28
29 error_reporting( E_ALL | E_STRICT );
30
31 if( !isset( $maintClass ) || !class_exists( $maintClass ) ) {
32 echo "\$maintClass is not set or is set to a non-existent class.";
33 die();
34 }
35
36 if( defined( 'MW_NO_SETUP' ) ) {
37 return;
38 }
39
40 // Get an object to start us off
41 $maintenance = new $maintClass();
42
43 // Basic sanity checks and such
44 $maintenance->setup();
45
46 // We used to call this variable $self, but it was moved
47 // to $maintenance->mSelf. Keep that here for b/c
48 $self = $maintenance->getName();
49
50 # Setup the profiler
51 if ( file_exists( "$IP/StartProfiler.php" ) ) {
52 require_once( "$IP/StartProfiler.php" );
53 } else {
54 require_once( "$IP/includes/ProfilerStub.php" );
55 }
56
57 // Load settings, using wikimedia-mode if needed
58 if( file_exists( dirname(__FILE__).'/wikimedia-mode' ) ) {
59 # TODO FIXME! Wikimedia-specific stuff needs to go away to an ext
60 # Maybe a hook?
61 global $cluster;
62 $wgWikiFarm = true;
63 $cluster = 'pmtma';
64 require_once( "$IP/includes/AutoLoader.php" );
65 require_once( "$IP/includes/SiteConfiguration.php" );
66 require( "$IP/wgConf.php" );
67 $maintenance->loadWikimediaSettings();
68 require( $IP.'/includes/Defines.php' );
69 require( $IP.'/CommonSettings.php' );
70 } else {
71 require_once( "$IP/includes/AutoLoader.php" );
72 require_once( "$IP/includes/Defines.php" );
73 require_once( $maintenance->loadSettings() );
74 }
75 // Some last includes
76 require_once( "$IP/includes/Setup.php" );
77 require_once( "$IP/install-utils.inc" );
78
79 // Much much faster startup than creating a title object
80 $wgTitle = null;
81
82 // Do the work
83 try {
84 $maintenance->execute();
85 } catch( MWException $mwe ) {
86 echo( $mwe->getText() );
87 }
88
89 // Potentially debug globals
90 $maintenance->globals();