Play safe and clear the article object internals, too (eg. mTouched).
[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 if ( !defined( 'DO_MAINTENANCE' ) ) {
30 echo "This file must be included after Maintenance.php\n";
31 exit( 1 );
32 }
33
34 if ( !$maintClass || !class_exists( $maintClass ) ) {
35 echo "\$maintClass is not set or is set to a non-existent class.\n";
36 exit( 1 );
37 }
38
39 if ( defined( 'MW_NO_SETUP' ) ) {
40 return;
41 }
42
43 // Get an object to start us off
44 $maintenance = new $maintClass();
45
46 // Basic sanity checks and such
47 $maintenance->setup();
48
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();
52
53 # Setup the profiler
54 global $IP;
55 if ( file_exists( "$IP/StartProfiler.php" ) ) {
56 require_once( "$IP/StartProfiler.php" );
57 } else {
58 require_once( "$IP/includes/ProfilerStub.php" );
59 }
60
61 // Some other requires
62 require_once( "$IP/includes/AutoLoader.php" );
63 require_once( "$IP/includes/Defines.php" );
64 require_once( "$IP/includes/DefaultSettings.php" );
65
66 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
67 # Use a callback function to configure MediaWiki
68 $callback = MW_CONFIG_CALLBACK;
69 # PHP 5.1 doesn't support "class::method" for call_user_func, so split it
70 if ( strpos( $callback, '::' ) !== false ) {
71 $callback = explode( '::', $callback, 2 );
72 }
73 call_user_func( $callback );
74 } elseif ( file_exists( "$IP/wmf-config/wikimedia-mode" ) ) {
75 // Load settings, using wikimedia-mode if needed
76 // Fixme: replace this hack with general farm-friendly code
77 # TODO FIXME! Wikimedia-specific stuff needs to go away to an ext
78 # Maybe a hook?
79 global $cluster;
80 $wgWikiFarm = true;
81 $cluster = 'pmtpa';
82 require_once( "$IP/includes/SiteConfiguration.php" );
83 require( "$IP/wmf-config/wgConf.php" );
84 $maintenance->loadWikimediaSettings();
85 require( $IP . '/wmf-config/CommonSettings.php' );
86 } else {
87 require_once( $maintenance->loadSettings() );
88 }
89
90 if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
91 is_readable( "$IP/AdminSettings.php" ) )
92 {
93 require( "$IP/AdminSettings.php" );
94 }
95 $maintenance->finalSetup();
96 // Some last includes
97 require_once( "$IP/includes/Setup.php" );
98 require_once( "$IP/maintenance/install-utils.inc" );
99
100 // Much much faster startup than creating a title object
101 $wgTitle = null;
102
103 // Do the work
104 try {
105 $maintenance->execute();
106
107 // Potentially debug globals
108 $maintenance->globals();
109 } catch ( MWException $mwe ) {
110 echo( $mwe->getText() );
111 exit( 1 );
112 }
113