production.
=== Configuration changes in 1.24 ===
+* The server's canonical hostname is available as $wgServerName, which is
+ exposed in both mw.config and ApiQuerySiteInfo.
=== New features in 1.24 ===
* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
*/
$wgCanonicalServer = false;
+/**
+ * Server name. This is automatically computed by parsing the bare
+ * hostname out of $wgCanonicalServer. It should not be customized.
+ * @since 1.24
+ */
+$wgServerName = false;
+
/************************************************************************//**
* @name Script path settings
* @{
* @{
*/
-$serverName = substr( $wgServer, strrpos( $wgServer, '/' ) + 1 );
/**
* Site admin email address.
+ *
+ * Defaults to "wikiadmin@{$wgServerName}".
*/
-$wgEmergencyContact = 'wikiadmin@' . $serverName;
+$wgEmergencyContact = false;
/**
* Password reminder email address.
*
* The address we should use as sender when a user is requesting his password.
+ *
+ * Defaults to "apache@{$wgServerName}".
*/
-$wgPasswordSender = 'apache@' . $serverName;
-
-unset( $serverName ); # Don't leak local variables to global scope
+$wgPasswordSender = false;
/**
* Password reminder name
}
// Set various default paths sensibly...
+
if ( $wgScript === false ) {
$wgScript = "$wgScriptPath/index$wgScriptExtension";
}
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.' );
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 ) {
$data['script'] = $GLOBALS['wgScript'];
$data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
$data['server'] = $GLOBALS['wgServer'];
+ $data['servername'] = $GLOBALS['wgServerName'];
$data['wikiid'] = wfWikiID();
$data['time'] = wfTimestamp( TS_ISO_8601, time() );
* @return string
*/
function getVariableValue( $index, $frame = false ) {
- global $wgContLang, $wgSitename, $wgServer;
+ global $wgContLang, $wgSitename, $wgServer, $wgServerName;
global $wgArticlePath, $wgScriptPath, $wgStylePath;
if ( is_null( $this->mTitle ) ) {
case 'server':
return $wgServer;
case 'servername':
- $serverParts = wfParseUrl( $wgServer );
- return $serverParts && isset( $serverParts['host'] ) ? $serverParts['host'] : $wgServer;
+ return $wgServerName;
case 'scriptpath':
return $wgScriptPath;
case 'stylepath':
}
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension,
- $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang,
- $wgVariantArticlePath, $wgActionPaths, $wgVersion,
+ $wgArticlePath, $wgScriptPath, $wgServer, $wgServerName,
+ $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion,
$wgEnableAPI, $wgEnableWriteAPI, $wgDBname,
$wgSitename, $wgFileExtensions, $wgExtensionAssetsPath,
$wgCookiePrefix, $wgResourceLoaderMaxQueryLength,
// becoming [] instead of {} in JS (bug 34604)
'wgActionPaths' => (object)$wgActionPaths,
'wgServer' => $wgServer,
+ 'wgServerName' => $wgServerName,
'wgUserLanguage' => $context->getLanguage(),
'wgContentLanguage' => $wgContLang->getCode(),
'wgVersion' => $wgVersion,
$settings = array(
'wgServer' => 'http://example.org',
+ 'wgServerName' => 'example.org',
'wgScript' => '/index.php',
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
$tmpGlobals['wgContLang'] = Language::factory( 'en' );
$tmpGlobals['wgSitename'] = 'MediaWiki';
$tmpGlobals['wgServer'] = 'http://example.org';
+ $tmpGlobals['wgServerName'] = 'example.org';
$tmpGlobals['wgScript'] = '/index.php';
$tmpGlobals['wgScriptPath'] = '/';
$tmpGlobals['wgArticlePath'] = '/wiki/$1';