MediaWiki  REL1_22
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 # Start the autoloader, so that extensions can derive classes from core files
00057 require_once "$IP/includes/AutoLoader.php";
00058 # Stub the profiler
00059 require_once "$IP/includes/profiler/Profiler.php";
00060 
00061 # Start the profiler
00062 $wgProfiler = array();
00063 if ( file_exists( "$IP/StartProfiler.php" ) ) {
00064     require "$IP/StartProfiler.php";
00065 }
00066 
00067 // Some other requires
00068 require_once "$IP/includes/Defines.php";
00069 require_once "$IP/includes/DefaultSettings.php";
00070 
00071 # Load composer's autoloader if present
00072 if ( is_readable( "$IP/vendor/autoload.php" ) ) {
00073     require_once "$IP/vendor/autoload.php";
00074 }
00075 
00076 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
00077     # Use a callback function to configure MediaWiki
00078     call_user_func( MW_CONFIG_CALLBACK );
00079 } else {
00080     if ( file_exists( "$IP/../wmf-config/wikimedia-mode" ) ) {
00081         // Load settings, using wikimedia-mode if needed
00082         // @todo FIXME: Replace this hack with general farm-friendly code
00083         # @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
00084         # Maybe a hook?
00085         global $cluster;
00086         $cluster = 'pmtpa';
00087         require "$IP/../wmf-config/wgConf.php";
00088     }
00089     // Require the configuration (probably LocalSettings.php)
00090     require $maintenance->loadSettings();
00091 }
00092 
00093 if ( $maintenance->getDbType() === Maintenance::DB_ADMIN &&
00094     is_readable( "$IP/AdminSettings.php" ) )
00095 {
00096     require "$IP/AdminSettings.php";
00097 }
00098 
00099 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
00100     if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
00101         $wgLocalisationCacheConf['storeClass'] = 'LCStore_Null';
00102     }
00103 }
00104 $maintenance->finalSetup();
00105 // Some last includes
00106 require_once "$IP/includes/Setup.php";
00107 
00108 // Much much faster startup than creating a title object
00109 $wgTitle = null;
00110 
00111 // Do the work
00112 try {
00113     $maintenance->execute();
00114 
00115     // Potentially debug globals
00116     $maintenance->globals();
00117 
00118     // Perform deferred updates.
00119     DeferredUpdates::doUpdates( 'commit' );
00120 
00121     // log profiling info
00122     wfLogProfilingData();
00123 
00124     // Commit and close up!
00125     $factory = wfGetLBFactory();
00126     $factory->commitMasterChanges();
00127     $factory->shutdown();
00128 } catch ( MWException $mwe ) {
00129     echo $mwe->getText();
00130     exit( 1 );
00131 }