Removed most exit() calls from the MediaWiki core, by replacing them with either...
[lhc/web/wiklou.git] / includes / Setup.php
index a28c047..acdca9c 100644 (file)
@@ -18,7 +18,8 @@ if( defined( 'MEDIAWIKI' ) ) {
 
 // Check to see if we are at the file scope
 if ( !isset( $wgVersion ) ) {
-       die( "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n" );
+       echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
+       die( 1 );
 }
 
 if( !isset( $wgProfiling ) )
@@ -42,18 +43,22 @@ if ( function_exists( 'wfProfileIn' ) ) {
 
 $fname = 'Setup.php';
 wfProfileIn( $fname );
+
+wfProfileIn( $fname.'-exception' );
+require_once( 'Exception.php' );
+wfInstallExceptionHandler();
+wfProfileOut( $fname.'-exception' );
+
 wfProfileIn( $fname.'-includes' );
 
+require_once( 'AutoLoader.php' );
 require_once( 'GlobalFunctions.php' );
 require_once( 'Hooks.php' );
 require_once( 'Namespace.php' );
 require_once( 'User.php' );
 require_once( 'Skin.php' );
 require_once( 'OutputPage.php' );
-require_once( 'LinkCache.php' );
-require_once( 'LinkBatch.php' );
 require_once( 'Title.php' );
-require_once( 'Article.php' );
 require_once( 'MagicWord.php' );
 require_once( 'Block.php' );
 require_once( 'MessageCache.php' );
@@ -64,9 +69,7 @@ require_once( 'LoadBalancer.php' );
 require_once( 'HistoryBlob.php' );
 require_once( 'ProxyTools.php' );
 require_once( 'ObjectCache.php' );
-require_once( 'WikiError.php' );
 require_once( 'SpecialPage.php' );
-require_once( 'RequestRate.php' );
 
 if ( $wgUseDynamicDates ) {
        require_once( 'DateFormatter.php' );
@@ -79,7 +82,11 @@ $wgIP = false; # Load on demand
 $wgRequest = new WebRequest();
 if ( function_exists( 'posix_uname' ) ) {
        $wguname = posix_uname();
+       $wgNodeName = $wguname['nodename'];
+} else {
+       $wgNodeName = '';
 }
+
 # Useful debug output
 if ( $wgCommandLineMode ) {
        # wfDebug( '"' . implode( '"  "', $argv ) . '"' );
@@ -116,12 +123,20 @@ wfProfileOut( $fname.'-memcached' );
 wfProfileIn( $fname.'-SetupSession' );
 
 if ( $wgDBprefix ) {
-       session_name( $wgDBname . '_' . $wgDBprefix . '_session' );
+       $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
+} elseif ( $wgSharedDB ) {
+       $wgCookiePrefix = $wgSharedDB;
 } else {
-       session_name( $wgDBname . '_session' );
+       $wgCookiePrefix = $wgDBname;
+}
+
+# If session.auto_start is there, we can't touch session name
+#
+if (!ini_get('session.auto_start')) {
+       session_name( $wgCookiePrefix . '_session' );
 }
 
-if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgDBname.'Token'] ) ) ) {
+if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
        wfIncrStats( 'request_with_session' );
        User::SetupSession();
        $wgSessionStarted = true;
@@ -191,10 +206,6 @@ wfProfileIn( $fname.'-User' );
 # Entries can be added to this variable during the inclusion
 # of the extension file. Skins can then perform any necessary initialisation.
 # 
-# require_once is slow even on the second call, so this needs to be outside the loop
-if ( count( $wgSkinExtensionFunctions ) ) {
-       require_once( 'PersistentObject.php' );
-}
 foreach ( $wgSkinExtensionFunctions as $func ) {
        call_user_func( $func );
 }
@@ -236,6 +247,8 @@ if( $wgLangClass == $wgContLangClass ) {
        $wgLang = &$wgContLang;
 } else {
        wfSuppressWarnings();
+       // Preload base classes to work around APC/PHP5 bug
+       include_once("$IP/languages/$wgLangClass.deps.php");
        include_once("$IP/languages/$wgLangClass.php");
        wfRestoreWarnings();
 
@@ -299,14 +312,6 @@ wfSeedRandom();
 $wgTitle = Title::makeTitle( NS_SPECIAL, 'Error' );
 $wgArticle = new Article($wgTitle);
 
-# Update request rate
-/*
-if ( !mt_rand( 0, $wgRequestRateDefaultFraction - 1 ) ) {
-       require_once( 'RequestRate.php' );
-       $rr =& RequestRate::singleton();
-       $rr->increment();
-}*/
-
 wfProfileOut( $fname.'-misc2' );
 wfProfileIn( $fname.'-extensions' );
 
@@ -314,13 +319,17 @@ wfProfileIn( $fname.'-extensions' );
 # Entries should be added to this variable during the inclusion
 # of the extension file. This allows the extension to perform
 # any necessary initialisation in the fully initialised environment
-if ( count( $wgExtensionFunctions ) ) {
-       require_once( 'PersistentObject.php' );
-}
 foreach ( $wgExtensionFunctions as $func ) {
        call_user_func( $func );
 }
 
+// For compatibility
+wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
+wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
+wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
+wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
+
+
 wfDebug( "\n" );
 $wgFullyInitialised = true;
 wfProfileOut( $fname.'-extensions' );