Save advanced search namespace prefs on Special:Search itself
[lhc/web/wiklou.git] / includes / Setup.php
index b155f90..a1bca22 100644 (file)
@@ -43,6 +43,7 @@ if ( !isset( $wgVersion ) ) {
 }
 
 // Set various default paths sensibly...
+
 if ( $wgScript === false ) {
        $wgScript = "$wgScriptPath/index$wgScriptExtension";
 }
@@ -122,7 +123,8 @@ if ( isset( $wgFooterIcons['poweredby'] )
        && isset( $wgFooterIcons['poweredby']['mediawiki'] )
        && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
 ) {
-       $wgFooterIcons['poweredby']['mediawiki']['src'] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
+       $wgFooterIcons['poweredby']['mediawiki']['src'] =
+               "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
 }
 
 /**
@@ -251,7 +253,10 @@ if ( $wgRCFilterByAge ) {
        // as determined by $wgRCMaxAge.
        // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
        sort( $wgRCLinkDays );
+
+       // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
        for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
+               // @codingStandardsIgnoreEnd
                if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
                        $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
                        break;
@@ -366,7 +371,9 @@ if ( $wgArticleCountMethod === null ) {
 }
 
 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
+       // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
        $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
+       // @codingStandardsIgnoreEnd
 }
 
 if ( $wgNewUserLog ) {
@@ -420,9 +427,34 @@ require_once "$IP/includes/normal/UtfNormalDefines.php";
 wfProfileOut( $fname . '-includes' );
 
 wfProfileIn( $fname . '-defaults2' );
+
+if ( $wgCanonicalServer === false ) {
+       $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
+}
+
+// Set server name
+$serverParts = wfParseUrl( $wgCanonicalServer );
+if ( $wgServerName !== false ) {
+       wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
+               . 'not customized. Overwriting $wgServerName.' );
+}
+$wgServerName = $serverParts['host'];
+unset( $serverParts );
+
+// Set defaults for configuration variables
+// that are derived from the server name by default
+if ( $wgEmergencyContact === false ) {
+       $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
+}
+
+if ( $wgPasswordSender === false ) {
+       $wgPasswordSender = 'apache@' . $wgServerName;
+}
+
 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
        $wgSecureLogin = false;
-       wfWarn( 'Secure login was enabled on a server that only supports HTTP or HTTPS. Disabling secure login.' );
+       wfWarn( 'Secure login was enabled on a server that only supports '
+               . 'HTTP or HTTPS. Disabling secure login.' );
 }
 
 // Now that GlobalFunctions is loaded, set defaults that depend
@@ -433,10 +465,6 @@ if ( $wgTmpDirectory === false ) {
        wfProfileOut( $fname . '-tempDir' );
 }
 
-if ( $wgCanonicalServer === false ) {
-       $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
-}
-
 // $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
 // ensure back compatibility.
 if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
@@ -531,13 +559,10 @@ if ( !wfIniGetBool( 'session.auto_start' ) ) {
        session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
 }
 
-if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
-       if ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
-               wfSetupSession();
-               $wgSessionStarted = true;
-       } else {
-               $wgSessionStarted = false;
-       }
+if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode &&
+       ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) )
+) {
+       wfSetupSession();
 }
 
 wfProfileOut( $fname . '-session' );