fix whitespace fixes
[lhc/web/wiklou.git] / includes / Setup.php
index a77f853..d30be72 100644 (file)
@@ -18,14 +18,18 @@ 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 ) )
        $wgProfiling = false;
 
-if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
+if ( function_exists( 'wfProfileIn' ) ) {
+       /* nada, everything should be done already */
+} elseif ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
        require_once( 'Profiling.php' );
+       $wgProfiling = true;
        if ($wgProfilerType == "") {
                $wgProfiler = new Profiler();
        } else {
@@ -34,22 +38,7 @@ if ( $wgProfiling and (0 == rand() % $wgProfileSampleRate ) ) {
                $wgProfiler = new $prclass();
        }
 } else {
-       function wfProfileIn( $fn = '' ) {
-               global $hackwhere, $wgDBname;
-               $hackwhere[] = $fn;
-               if (function_exists("setproctitle"))
-                       setproctitle($fn . " [$wgDBname]");
-       }
-       function wfProfileOut( $fn = '' ) {
-               global $hackwhere, $wgDBname;
-               if (count($hackwhere))
-                       array_pop($hackwhere);
-               if (function_exists("setproctitle") && count($hackwhere))
-                       setproctitle($hackwhere[count($hackwhere)-1] . " [$wgDBname]");
-       }
-       function wfGetProfilingOutput( $s, $e ) {}
-       function wfProfileClose() {}
-       function wfLogProfilingData() {}
+       require_once( 'ProfilerStub.php' );
 }
 
 $fname = 'Setup.php';
@@ -59,11 +48,11 @@ wfProfileIn( $fname.'-includes' );
 require_once( 'GlobalFunctions.php' );
 require_once( 'Hooks.php' );
 require_once( 'Namespace.php' );
-require_once( 'RecentChange.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' );
@@ -88,7 +77,9 @@ wfProfileIn( $fname.'-misc1' );
 
 $wgIP = false; # Load on demand
 $wgRequest = new WebRequest();
-
+if ( function_exists( 'posix_uname' ) ) {
+       $wguname = posix_uname();
+}
 # Useful debug output
 if ( $wgCommandLineMode ) {
        # wfDebug( '"' . implode( '"  "', $argv ) . '"' );
@@ -125,15 +116,25 @@ 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( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgDBname.'Token'] ) ) ) {
+# 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[$wgCookiePrefix.'Token'] ) ) ) {
+       wfIncrStats( 'request_with_session' );
        User::SetupSession();
        $wgSessionStarted = true;
 } else {
+       wfIncrStats( 'request_without_session' );
        $wgSessionStarted = false;
 }
 
@@ -197,9 +198,12 @@ wfProfileIn( $fname.'-User' );
 # Skin setup functions
 # 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 ) {
-       require_once 'PersistentObject.php';
-
        call_user_func( $func );
 }
 
@@ -240,6 +244,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();
 
@@ -286,10 +292,8 @@ wfProfileIn( $fname.'-misc2' );
 $wgDeferredUpdateList = array();
 $wgPostCommitUpdateList = array();
 
-$wgLinkCache = new LinkCache();
 $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
-$wgParserCache = new ParserCache( $messageMemc );
 
 if ( $wgUseXMLparser ) {
        require_once( 'ParserXML.php' );
@@ -312,9 +316,10 @@ 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 ) {
-       require_once 'PersistentObject.php';
-
        call_user_func( $func );
 }