MediaWiki  REL1_23
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_NONE ) {
00094     if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
00095         $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
00096     }
00097 }
00098 $maintenance->finalSetup();
00099 // Some last includes
00100 require_once "$IP/includes/Setup.php";
00101 
00102 // Do the work
00103 try {
00104     $maintenance->execute();
00105 
00106     // Potentially debug globals
00107     $maintenance->globals();
00108 
00109     // Perform deferred updates.
00110     DeferredUpdates::doUpdates( 'commit' );
00111 
00112     // log profiling info
00113     wfLogProfilingData();
00114 
00115     // Commit and close up!
00116     $factory = wfGetLBFactory();
00117     $factory->commitMasterChanges();
00118     $factory->shutdown();
00119 } catch ( MWException $mwe ) {
00120     echo $mwe->getText();
00121     exit( 1 );
00122 }