* (bug 23276) Add hook to Special:NewPages to modify query
[mediawiki.git] / maintenance / doMaintenance.php
blob008c5b87e1b05b0e3216b25d576c40b3ae10d30e
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
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.
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.
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
24 * @author Chad Horohoe <chad@anyonecanedit.org>
25 * @file
26 * @ingroup Maintenance
29 if ( !defined( 'DO_MAINTENANCE' ) ) {
30 echo "This file must be included after Maintenance.php\n";
31 exit( 1 );
34 if( !$maintClass || !class_exists( $maintClass ) ) {
35 echo "\$maintClass is not set or is set to a non-existent class.\n";
36 exit( 1 );
39 if( defined( 'MW_NO_SETUP' ) ) {
40 return;
43 // Get an object to start us off
44 $maintenance = new $maintClass();
46 // Basic sanity checks and such
47 $maintenance->setup();
49 // We used to call this variable $self, but it was moved
50 // to $maintenance->mSelf. Keep that here for b/c
51 $self = $maintenance->getName();
53 # Setup the profiler
54 if ( file_exists( "$IP/StartProfiler.php" ) ) {
55 require_once( "$IP/StartProfiler.php" );
56 } else {
57 require_once( "$IP/includes/ProfilerStub.php" );
60 // Some other requires
61 require_once( "$IP/includes/AutoLoader.php" );
62 require_once( "$IP/includes/Defines.php" );
64 // Load settings, using wikimedia-mode if needed
65 // Fixme: replace this hack with general farm-friendly code
66 if( file_exists( "$IP/wmf-config/wikimedia-mode" ) ) {
67 # TODO FIXME! Wikimedia-specific stuff needs to go away to an ext
68 # Maybe a hook?
69 global $cluster;
70 $wgWikiFarm = true;
71 $cluster = 'pmtpa';
72 require_once( "$IP/includes/SiteConfiguration.php" );
73 require( "$IP/wmf-config/wgConf.php" );
74 $maintenance->loadWikimediaSettings();
75 require( $IP.'/wmf-config/CommonSettings.php' );
76 } else {
77 require_once( $maintenance->loadSettings() );
79 if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
80 is_readable( "$IP/AdminSettings.php" ) )
82 require( "$IP/AdminSettings.php" );
84 $maintenance->finalSetup();
85 // Some last includes
86 require_once( "$IP/includes/Setup.php" );
87 require_once( "$IP/maintenance/install-utils.inc" );
89 // Much much faster startup than creating a title object
90 $wgTitle = null;
92 // Do the work
93 try {
94 $maintenance->execute();
96 // Potentially debug globals
97 $maintenance->globals();
98 } catch( MWException $mwe ) {
99 echo( $mwe->getText() );
100 exit( 1 );