Merge "Don't set the session name in CLI or when sessions are deactivated"
[lhc/web/wiklou.git] / includes / Setup.php
index 1eb04c3..c84b50a 100644 (file)
@@ -78,14 +78,6 @@ if ( $wgExtensionAssetsPath === false ) {
        $wgExtensionAssetsPath = "$wgScriptPath/extensions";
 }
 
-// Enable default skins. Temporary, to be removed before 1.24 release.
-// This is hacky and bad, the require_once calls should eventually be generated by the installer
-// and placed in LocalSettings.php.
-// While this is in Setup.php, it needs to be done as soon as possible, as some of the setup code
-// depends on all extensions and skins being already required (bug 67318).
-require_once "$wgStyleDirectory/MonoBook/MonoBook.php";
-require_once "$wgStyleDirectory/Vector/Vector.php";
-
 if ( $wgLogo === false ) {
        $wgLogo = "$wgStylePath/common/images/wiki.png";
 }
@@ -271,8 +263,21 @@ if ( $wgSkipSkin ) {
        $wgSkipSkins[] = $wgSkipSkin;
 }
 
-// Register a hidden "fallback" skin
-$wgValidSkinNames['fallback'] = 'Fallback'; // SkinFallback
+// Register skins
+// Use a closure to avoid leaking into global state
+call_user_func( function() use ( $wgValidSkinNames ) {
+       $factory = SkinFactory::getDefaultInstance();
+       foreach ( $wgValidSkinNames as $name => $skin ) {
+               $factory->register( $name, $skin, function() use ( $name, $skin ) {
+                       $class = "Skin$skin";
+                       return new $class( $name );
+               } );
+       }
+       // Register a hidden "fallback" skin
+       $factory->register( 'fallback', 'Fallback', function() {
+               return new SkinFallback;
+       } );
+} );
 $wgSkipSkins[] = 'fallback';
 
 if ( $wgLocalInterwiki ) {
@@ -473,23 +478,6 @@ if ( $wgTmpDirectory === false ) {
        wfProfileOut( $fname . '-tempDir' );
 }
 
-// $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
-// ensure back compatibility.
-if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
-       $wgHTCPRouting = $wgHTCPMulticastRouting;
-}
-
-// Initialize $wgHTCPRouting from backwards-compatible settings that
-// comes from pre 1.20 version.
-if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
-       $wgHTCPRouting = array(
-               '' => array(
-                       'host' => $wgHTCPMulticastAddress,
-                       'port' => $wgHTCPPort,
-               )
-       );
-}
-
 // Back compatibility for $wgRateLimitLog deprecated with 1.23
 if ( $wgRateLimitLog && !array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
        $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
@@ -562,15 +550,15 @@ wfRunHooks( 'SetupAfterCache' );
 
 wfProfileIn( $fname . '-session' );
 
-// If session.auto_start is there, we can't touch session name
-if ( !wfIniGetBool( 'session.auto_start' ) ) {
-       session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
-}
+if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
+       // If session.auto_start is there, we can't touch session name
+       if ( !wfIniGetBool( 'session.auto_start' ) ) {
+               session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
+       }
 
-if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode &&
-       ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) )
-) {
-       wfSetupSession();
+       if ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
+               wfSetupSession();
+       }
 }
 
 wfProfileOut( $fname . '-session' );