Added some constants to speed up Setup.php
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 22 Dec 2013 23:19:23 +0000 (15:19 -0800)
committerReedy <reedy@wikimedia.org>
Sat, 25 Jan 2014 04:37:32 +0000 (04:37 +0000)
Change-Id: I528b362d6ef3d07c6c301e7a1767a1be0fc93725

includes/Setup.php
maintenance/getConfiguration.php

index 531d1a4..d1269ad 100644 (file)
@@ -417,8 +417,8 @@ MWExceptionHandler::installHandler();
 wfProfileOut( $fname . '-exception' );
 
 wfProfileIn( $fname . '-includes' );
-require_once "$IP/includes/normal/UtfNormalUtil.php";
 require_once "$IP/includes/GlobalFunctions.php";
+require_once "$IP/includes/normal/UtfNormalUtil.php";
 require_once "$IP/includes/normal/UtfNormalDefines.php";
 wfProfileOut( $fname . '-includes' );
 
@@ -457,6 +457,8 @@ if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
        );
 }
 
+$wgDeferredUpdateList = array(); // b/c
+
 wfProfileOut( $fname . '-defaults2' );
 wfProfileIn( $fname . '-misc1' );
 
@@ -501,21 +503,22 @@ if ( $wgCommandLineMode ) {
 }
 
 wfProfileOut( $fname . '-misc1' );
-wfProfileIn( $fname . '-memcached' );
-
-$wgMemc = wfGetMainCache();
-$messageMemc = wfGetMessageCacheStorage();
-$parserMemc = wfGetParserCacheStorage();
-$wgLangConvMemc = wfGetLangConverterCacheStorage();
+if ( !defined( 'MW_SETUP_NO_CACHE' ) ) {
+       wfProfileIn( $fname . '-memcached' );
 
-wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' .
-       get_class( $messageMemc ) . '[message] ' .
-       get_class( $parserMemc ) . "[parser]\n" );
+       $wgMemc = wfGetMainCache();
+       $messageMemc = wfGetMessageCacheStorage();
+       $parserMemc = wfGetParserCacheStorage();
+       $wgLangConvMemc = wfGetLangConverterCacheStorage();
 
-wfProfileOut( $fname . '-memcached' );
+       wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' .
+               get_class( $messageMemc ) . '[message] ' .
+               get_class( $parserMemc ) . "[parser]\n" );
 
-# # Most of the config is out, some might want to run hooks here.
-wfRunHooks( 'SetupAfterCache' );
+       wfProfileOut( $fname . '-memcached' );
+       # # Most of the config is out, some might want to run hooks here.
+       wfRunHooks( 'SetupAfterCache' );
+}
 
 wfProfileIn( $fname . '-session' );
 
@@ -534,42 +537,44 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
 }
 
 wfProfileOut( $fname . '-session' );
-wfProfileIn( $fname . '-globals' );
 
-$wgContLang = Language::factory( $wgLanguageCode );
-$wgContLang->initEncoding();
-$wgContLang->initContLang();
+if ( !defined( 'MW_SETUP_NO_CONTEXT' ) ) {
+       wfProfileIn( $fname . '-globals' );
 
-// Now that variant lists may be available...
-$wgRequest->interpolateTitle();
-$wgUser = RequestContext::getMain()->getUser(); # BackCompat
+       $wgContLang = Language::factory( $wgLanguageCode );
+       $wgContLang->initEncoding();
+       $wgContLang->initContLang();
 
-/**
- * @var $wgLang Language
- */
-$wgLang = new StubUserLang;
+       // Now that variant lists may be available...
+       $wgRequest->interpolateTitle();
+       $wgUser = RequestContext::getMain()->getUser(); # BackCompat
 
-/**
* @var OutputPage
- */
-$wgOut = RequestContext::getMain()->getOutput(); # BackCompat
+       /**
       * @var $wgLang Language
       */
+       $wgLang = new StubUserLang;
 
-/**
- * @var $wgParser Parser
- */
-$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
+       /**
+        * @var OutputPage
       */
+       $wgOut = RequestContext::getMain()->getOutput(); # BackCompat
 
-if ( !is_object( $wgAuth ) ) {
-       $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
-       wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
-}
+       /**
+        * @var $wgParser Parser
+        */
+       $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
 
-# Placeholders in case of DB error
-$wgTitle = null;
+       if ( !is_object( $wgAuth ) ) {
+               $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
+               wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
+       }
+
+       # Placeholders in case of DB error
+       $wgTitle = null;
 
-$wgDeferredUpdateList = array();
+       wfProfileOut( $fname . '-globals' );
+}
 
-wfProfileOut( $fname . '-globals' );
 wfProfileIn( $fname . '-extensions' );
 
 # Extension setup functions for extensions other than skins
index 52cb209..60bb8d8 100644 (file)
@@ -23,6 +23,8 @@
  * @author Antoine Musso <hashar@free.fr>
  */
 
+define( 'MW_SETUP_NO_CACHE', 1 );
+define( 'MW_SETUP_NO_CONTEXT', 1 );
 require_once __DIR__ . '/Maintenance.php';
 
 /**