<?php
/**
- * Include most things that's need to customize the site.
+ * Include most things that are needed to make %MediaWiki work.
+ *
+ * This file is included by WebStart.php and doMaintenance.php so that both
+ * web and maintenance scripts share a final set up phase to include necessary
+ * files and create global object variables.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
exit( 1 );
}
-# The main wiki script and things like database
-# conversion and maintenance scripts all share a
-# common setup of including lots of classes and
-# setting up a few globals.
-#
-
$fname = 'Setup.php';
wfProfileIn( $fname );
wfProfileIn( $fname . '-defaults' );
}
// Set various default paths sensibly...
+
if ( $wgScript === false ) {
$wgScript = "$wgScriptPath/index$wgScriptExtension";
}
}
if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
- # 'view' is assumed the default action path everywhere in the code
- # but is rarely filled in $wgActionPaths
+ // 'view' is assumed the default action path everywhere in the code
+ // but is rarely filled in $wgActionPaths
$wgActionPaths['view'] = $wgArticlePath;
}
&& 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";
}
/**
unset( $repo ); // no global pollution; destroy reference
if ( $wgRCFilterByAge ) {
- # # Trim down $wgRCLinkDays so that it only lists links which are valid
- # # as determined by $wgRCMaxAge.
- # # Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
+ // Trim down $wgRCLinkDays so that it only lists links which are valid
+ // 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;
array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
}
-# Set default shared prefix
+// Set default shared prefix
if ( $wgSharedPrefix === false ) {
$wgSharedPrefix = $wgDBprefix;
}
$wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
}
-# These are now the same, always
-# To determine the user language, use $wgLang->getCode()
+// These are now the same, always
+// To determine the user language, use $wgLang->getCode()
$wgContLanguageCode = $wgLanguageCode;
-# Easy to forget to falsify $wgShowIPinHeader for static caches.
-# If file cache or squid cache is on, just disable this (DWIMD).
-# Do the same for $wgDebugToolbar.
+// Easy to forget to falsify $wgShowIPinHeader for static caches.
+// If file cache or squid cache is on, just disable this (DWIMD).
+// Do the same for $wgDebugToolbar.
if ( $wgUseFileCache || $wgUseSquid ) {
$wgShowIPinHeader = false;
$wgDebugToolbar = false;
}
-# Doesn't make sense to have if disabled.
+// Doesn't make sense to have if disabled.
if ( !$wgEnotifMinorEdits ) {
$wgHiddenPrefs[] = 'enotifminoredits';
}
-# We always output HTML5 since 1.22, overriding these is no longer supported
-# we set them here for extensions that depend on its value.
+// We always output HTML5 since 1.22, overriding these is no longer supported
+// we set them here for extensions that depend on its value.
$wgHtml5 = true;
$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
$wgJsMimeType = 'text/javascript';
if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
- # see http://www.w3.org/TR/rdfa-in-html/#document-conformance
+ // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
if ( $wgMimeType == 'application/xhtml+xml' ) {
$wgHtml5Version = 'XHTML+RDFa 1.0';
} else {
}
}
-# Blacklisted file extensions shouldn't appear on the "allowed" list
+// Blacklisted file extensions shouldn't appear on the "allowed" list
$wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
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 ) {
- # Add a new log type
+ // Add a new log type
$wgLogTypes[] = 'newusers';
$wgLogNames['newusers'] = 'newuserlogpage';
$wgLogHeaders['newusers'] = 'newuserlogpagetext';
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
-# on it.
+// Now that GlobalFunctions is loaded, set defaults that depend
+// on it.
if ( $wgTmpDirectory === false ) {
wfProfileIn( $fname . '-tempDir' );
$wgTmpDirectory = wfTempDir();
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 ) {
wfProfileOut( $fname . '-defaults2' );
wfProfileIn( $fname . '-misc1' );
-# Raise the memory limit if it's too low
+// Raise the memory limit if it's too low
wfMemoryLimit();
/**
$wgLocalTZoffset = date( 'Z' ) / 60;
}
-# Useful debug output
+// Useful debug output
if ( $wgCommandLineMode ) {
$wgRequest = new FauxRequest( array() );
wfDebug( "\n\nStart command line script $self\n" );
} else {
- # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
+ // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
$wgRequest = new WebRequest;
$debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
$parserMemc = wfGetParserCacheStorage();
$wgLangConvMemc = wfGetLangConverterCacheStorage();
-wfDebugLog( 'caches', get_class( $wgMemc ) . '[main] ' .
- get_class( $messageMemc ) . '[message] ' .
- get_class( $parserMemc ) . '[parser]' );
+wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
+ ', message: ' . get_class( $messageMemc ) .
+ ', parser: ' . get_class( $parserMemc ) );
wfProfileOut( $fname . '-memcached' );
-# # Most of the config is out, some might want to run hooks here.
+// Most of the config is out, some might want to run hooks here.
wfRunHooks( 'SetupAfterCache' );
wfProfileIn( $fname . '-session' );
-# If session.auto_start is there, we can't touch session name
+// 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 ( $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' );
// Now that variant lists may be available...
$wgRequest->interpolateTitle();
-$wgUser = RequestContext::getMain()->getUser(); # BackCompat
+$wgUser = RequestContext::getMain()->getUser(); // BackCompat
/**
* @var $wgLang Language
/**
* @var OutputPage
*/
-$wgOut = RequestContext::getMain()->getOutput(); # BackCompat
+$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
/**
* @var $wgParser Parser
wfProfileOut( $fname . '-globals' );
wfProfileIn( $fname . '-extensions' );
-# Extension setup functions for extensions other than skins
-# 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
+// Extension setup functions for extensions other than skins
+// 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
foreach ( $wgExtensionFunctions as $func ) {
- # Allow closures in PHP 5.3+
+ // Allow closures in PHP 5.3+
if ( is_object( $func ) && $func instanceof Closure ) {
$profName = $fname . '-extensions-closure';
} elseif ( is_array( $func ) ) {