Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / doMaintenance.php
blob2e138e0f8f7517c46604a5788ce35fd8363ee1d0
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( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
30 echo "This file must be included after Maintenance.php\n";
31 exit( 1 );
34 // Wasn't included from the file scope, halt execution (probably wanted the class)
35 // If a class is using commandLine.inc (old school maintenance), they definitely
36 // cannot be included and will proceed with execution
37 if ( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) {
38 return;
41 if ( !$maintClass || !class_exists( $maintClass ) ) {
42 echo "\$maintClass is not set or is set to a non-existent class.\n";
43 exit( 1 );
46 // Get an object to start us off
47 $maintenance = new $maintClass();
49 // Basic sanity checks and such
50 $maintenance->setup();
52 // We used to call this variable $self, but it was moved
53 // to $maintenance->mSelf. Keep that here for b/c
54 $self = $maintenance->getName();
56 // Detect compiled mode
57 if ( isset( $_SERVER['MW_COMPILED'] ) ) {
58 define( 'MW_COMPILED', 1 );
59 } else {
60 # Get the MWInit class
61 require_once( "$IP/includes/Init.php" );
62 require_once( "$IP/includes/AutoLoader.php" );
63 # Stub the profiler
64 require_once( "$IP/includes/profiler/Profiler.php" );
67 # Start the profiler
68 $wgProfiler = array();
69 if ( file_exists( "$IP/StartProfiler.php" ) ) {
70 require( "$IP/StartProfiler.php" );
73 // Some other requires
74 if ( !defined( 'MW_COMPILED' ) ) {
75 require_once( "$IP/includes/Defines.php" );
77 require_once( MWInit::compiledPath( 'includes/DefaultSettings.php' ) );
79 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
80 # Use a callback function to configure MediaWiki
81 MWFunction::call( MW_CONFIG_CALLBACK );
82 } else {
83 if ( file_exists( "$IP/../wmf-config/wikimedia-mode" ) ) {
84 // Load settings, using wikimedia-mode if needed
85 // @todo FIXME: Replace this hack with general farm-friendly code
86 # @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
87 # Maybe a hook?
88 global $cluster;
89 $cluster = 'pmtpa';
90 require( MWInit::interpretedPath( '../wmf-config/wgConf.php' ) );
92 // Require the configuration (probably LocalSettings.php)
93 require( $maintenance->loadSettings() );
96 if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
97 is_readable( "$IP/AdminSettings.php" ) )
99 require( MWInit::interpretedPath( 'AdminSettings.php' ) );
102 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
103 if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
104 $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
107 $maintenance->finalSetup();
108 // Some last includes
109 require_once( MWInit::compiledPath( 'includes/Setup.php' ) );
111 // Much much faster startup than creating a title object
112 $wgTitle = null;
114 // Do the work
115 try {
116 $maintenance->execute();
118 // Potentially debug globals
119 $maintenance->globals();
121 // Perform deferred updates.
122 DeferredUpdates::doUpdates( 'commit' );
124 // log profiling info
125 wfLogProfilingData();
127 // Commit and close up!
128 $factory = wfGetLBFactory();
129 $factory->commitMasterChanges();
130 $factory->shutdown();
131 } catch ( MWException $mwe ) {
132 echo( $mwe->getText() );
133 exit( 1 );