MediaWiki  REL1_19
doMaintenance.php
Go to the documentation of this file.
00001 <?php
00029 if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
00030         echo "This file must be included after Maintenance.php\n";
00031         exit( 1 );
00032 }
00033 
00034 // Wasn't included from the file scope, halt execution (probably wanted the class)
00035 // If a class is using commandLine.inc (old school maintenance), they definitely
00036 // cannot be included and will proceed with execution
00037 if( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) {
00038         return;
00039 }
00040 
00041 if ( !$maintClass || !class_exists( $maintClass ) ) {
00042         echo "\$maintClass is not set or is set to a non-existent class.\n";
00043         exit( 1 );
00044 }
00045 
00046 // Get an object to start us off
00047 $maintenance = new $maintClass();
00048 
00049 // Basic sanity checks and such
00050 $maintenance->setup();
00051 
00052 // We used to call this variable $self, but it was moved
00053 // to $maintenance->mSelf. Keep that here for b/c
00054 $self = $maintenance->getName();
00055 
00056 // Detect compiled mode
00057 if ( isset( $_SERVER['MW_COMPILED'] ) ) {
00058         define( 'MW_COMPILED', 1 );
00059 } else {
00060         # Get the MWInit class
00061         require_once( "$IP/includes/Init.php" );
00062         require_once( "$IP/includes/AutoLoader.php" );
00063 }
00064 
00065 # Stub the profiler
00066 require_once( MWInit::compiledPath( 'includes/profiler/Profiler.php' ) );
00067 
00068 // Some other requires
00069 if ( !defined( 'MW_COMPILED' ) ) {
00070         require_once( "$IP/includes/Defines.php" );
00071 }
00072 require_once( MWInit::compiledPath( 'includes/DefaultSettings.php' ) );
00073 
00074 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
00075         # Use a callback function to configure MediaWiki
00076         MWFunction::call( MW_CONFIG_CALLBACK );
00077 } else {
00078         if ( file_exists( "$IP/../wmf-config/wikimedia-mode" ) ) {
00079                 // Load settings, using wikimedia-mode if needed
00080                 // @todo FIXME: Replace this hack with general farm-friendly code
00081                 # @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
00082                 # Maybe a hook?
00083                 global $cluster;
00084                 $cluster = 'pmtpa';
00085                 require( MWInit::interpretedPath( '../wmf-config/wgConf.php' ) );
00086         }
00087         // Require the configuration (probably LocalSettings.php)
00088         require( $maintenance->loadSettings() );
00089 }
00090 
00091 if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
00092         is_readable( "$IP/AdminSettings.php" ) )
00093 {
00094         require( MWInit::interpretedPath( 'AdminSettings.php' ) );
00095 }
00096 $maintenance->finalSetup();
00097 // Some last includes
00098 require_once( MWInit::compiledPath( 'includes/Setup.php' ) );
00099 
00100 // Much much faster startup than creating a title object
00101 $wgTitle = null;
00102 
00103 // Do the work
00104 try {
00105         $maintenance->execute();
00106 
00107         // Potentially debug globals
00108         $maintenance->globals();
00109 } catch ( MWException $mwe ) {
00110         echo( $mwe->getText() );
00111         exit( 1 );
00112 }
00113