Merge "Some cleanups to MWExceptionHandler::handleException"
[lhc/web/wiklou.git] / maintenance / doMaintenance.php
index 3ffee10..4b9ad9c 100644 (file)
@@ -44,6 +44,7 @@ if ( !$maintClass || !class_exists( $maintClass ) ) {
 }
 
 // Get an object to start us off
+/** @var Maintenance $maintenance */
 $maintenance = new $maintClass();
 
 // Basic sanity checks and such
@@ -53,7 +54,26 @@ $maintenance->setup();
 // to $maintenance->mSelf. Keep that here for b/c
 $self = $maintenance->getName();
 
-require_once "$IP/includes/Initialize.php";
+# Start the autoloader, so that extensions can derive classes from core files
+require_once "$IP/includes/AutoLoader.php";
+# Grab profiling functions
+require_once "$IP/includes/profiler/ProfilerFunctions.php";
+
+# Start the profiler
+$wgProfiler = array();
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+       require "$IP/StartProfiler.php";
+}
+
+// Some other requires
+require_once "$IP/includes/Defines.php";
+require_once "$IP/includes/DefaultSettings.php";
+require_once "$IP/includes/GlobalFunctions.php";
+
+# Load composer's autoloader if present
+if ( is_readable( "$IP/vendor/autoload.php" ) ) {
+       require_once "$IP/vendor/autoload.php";
+}
 
 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        # Use a callback function to configure MediaWiki
@@ -71,28 +91,27 @@ if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
                $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
        }
 }
+
 $maintenance->finalSetup();
 // Some last includes
 require_once "$IP/includes/Setup.php";
 
+// Initialize main config instance
+$maintenance->setConfig( ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
+
 // Do the work
-try {
-       $maintenance->execute();
+$maintenance->execute();
 
-       // Potentially debug globals
-       $maintenance->globals();
+// Potentially debug globals
+$maintenance->globals();
 
-       // Perform deferred updates.
-       DeferredUpdates::doUpdates( 'commit' );
+// Perform deferred updates.
+DeferredUpdates::doUpdates( 'commit' );
 
-       // log profiling info
-       wfLogProfilingData();
+// log profiling info
+wfLogProfilingData();
 
-       // Commit and close up!
-       $factory = wfGetLBFactory();
-       $factory->commitMasterChanges();
-       $factory->shutdown();
-} catch ( MWException $mwe ) {
-       echo $mwe->getText();
-       exit( 1 );
-}
+// Commit and close up!
+$factory = wfGetLBFactory();
+$factory->commitMasterChanges();
+$factory->shutdown();