None of the 3 globals based on it changed if you set it in LocalSettings.
Note that all those !isset( $wgServerName ) in ApiTests were useless, since if not in LocalSettings it would be 'localhost', not null (as still are those !isset( $wgServer )).
intelligently:
* $wgEmergencyContact: An e-mail address that can be used to contact the wiki
intelligently:
* $wgEmergencyContact: An e-mail address that can be used to contact the wiki
- administrator. By default, "wikiadmin@$wgServerName".
+ administrator. By default, "wikiadmin@ServerName".
* $wgPasswordSender: The e-mail address to use when sending password e-mails.
* $wgPasswordSender: The e-mail address to use when sending password e-mails.
- By default, "MediaWiki Mail <apache@$wgServerName>".
+ By default, "MediaWiki Mail <apache@ServerName>".
+ (with ServerName guessed from the http request)
* $wgSMTP: Can be configured to use SMTP for mail sending instead of PHP
mail().
* $wgSMTP: Can be configured to use SMTP for mail sending instead of PHP
mail().
/** @cond file_level_code */
if( isset( $_SERVER['SERVER_NAME'] ) ) {
/** @cond file_level_code */
if( isset( $_SERVER['SERVER_NAME'] ) ) {
- $wgServerName = $_SERVER['SERVER_NAME'];
+ $serverName = $_SERVER['SERVER_NAME'];
} elseif( isset( $_SERVER['HOSTNAME'] ) ) {
} elseif( isset( $_SERVER['HOSTNAME'] ) ) {
- $wgServerName = $_SERVER['HOSTNAME'];
+ $serverName = $_SERVER['HOSTNAME'];
} elseif( isset( $_SERVER['HTTP_HOST'] ) ) {
} elseif( isset( $_SERVER['HTTP_HOST'] ) ) {
- $wgServerName = $_SERVER['HTTP_HOST'];
+ $serverName = $_SERVER['HTTP_HOST'];
} elseif( isset( $_SERVER['SERVER_ADDR'] ) ) {
} elseif( isset( $_SERVER['SERVER_ADDR'] ) ) {
- $wgServerName = $_SERVER['SERVER_ADDR'];
+ $serverName = $_SERVER['SERVER_ADDR'];
- $wgServerName = 'localhost';
+ $serverName = 'localhost';
}
$wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
}
$wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
-$wgServer = $wgProto.'://' . $wgServerName;
+$wgServer = $wgProto.'://' . $serverName;
# If the port is a non-standard one, add it to the URL
if( isset( $_SERVER['SERVER_PORT'] )
# If the port is a non-standard one, add it to the URL
if( isset( $_SERVER['SERVER_PORT'] )
- && !strpos( $wgServerName, ':' )
+ && !strpos( $serverName, ':' )
&& ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
|| ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) {
&& ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
|| ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) {
/**
* Site admin email address.
*/
/**
* Site admin email address.
*/
-$wgEmergencyContact = 'wikiadmin@' . $wgServerName;
+$wgEmergencyContact = 'wikiadmin@' . $serverName;
/**
* Password reminder email address.
*
* The address we should use as sender when a user is requesting his password.
*/
/**
* Password reminder email address.
*
* The address we should use as sender when a user is requesting his password.
*/
-$wgPasswordSender = 'MediaWiki Mail <apache@' . $wgServerName . '>';
+$wgPasswordSender = 'MediaWiki Mail <apache@' . $serverName . '>';
+
+unset($serverName); # Don't leak local variables to global scope
/**
* Dummy address which should be accepted during mail send action.
/**
* Dummy address which should be accepted during mail send action.
* @private
*/
function getVariableValue( $index, $frame=false ) {
* @private
*/
function getVariableValue( $index, $frame=false ) {
- global $wgContLang, $wgSitename, $wgServer, $wgServerName;
+ global $wgContLang, $wgSitename, $wgServer;
global $wgArticlePath, $wgScriptPath, $wgStylePath;
/**
global $wgArticlePath, $wgScriptPath, $wgStylePath;
/**
case 'server':
return $wgServer;
case 'servername':
case 'server':
return $wgServer;
case 'servername':
+ wfSuppressWarnings(); # May give an E_WARNING in PHP < 5.3.3
+ $serverName = parse_url( $wgServer, PHP_URL_HOST );
+ wfRestoreWarnings();
+ return $serverName ? $serverName : $wgServer;
case 'scriptpath':
return $wgScriptPath;
case 'stylepath':
case 'scriptpath':
return $wgScriptPath;
case 'stylepath':
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$settings = array(
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$settings = array(
- 'wgServer' => 'http://localhost',
+ 'wgServer' => 'http://Britney-Spears',
'wgScript' => '/index.php',
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
'wgScript' => '/index.php',
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
'wgStylePath' => '/skins',
'wgStyleSheetPath' => '/skins',
'wgSitename' => 'MediaWiki',
'wgStylePath' => '/skins',
'wgStyleSheetPath' => '/skins',
'wgSitename' => 'MediaWiki',
- 'wgServerName' => 'Britney-Spears',
'wgLanguageCode' => $lang,
'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
'wgRawHtml' => isset( $opts['rawhtml'] ),
'wgLanguageCode' => $lang,
'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
'wgRawHtml' => isset( $opts['rawhtml'] ),
!! input
{{SERVER}}
!! result
!! input
{{SERVER}}
!! result
-<p><a href="http://localhost" class="external free" rel="nofollow">http://localhost</a>
+<p><a href="http://Britney-Spears" class="external free" rel="nofollow">http://Britney-Spears</a>
- global $wgServerName, $wgServer;
- if ( !isset( $wgServerName ) || !isset( $wgServer ) ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( !isset( $wgServer ) ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
/* Haven't thought about test ordering yet -- but this depends on HttpTest.php */
$resp = Http::get( self::$apiUrl . "?format=xml" );
}
/* Haven't thought about test ordering yet -- but this depends on HttpTest.php */
$resp = Http::get( self::$apiUrl . "?format=xml" );
}
function testApiLoginNoName() {
}
function testApiLoginNoName() {
- global $wgServerName, $wgServer;
- if ( !isset( $wgServerName ) || !isset( $wgServer ) ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( !isset( $wgServer ) ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
$resp = Http::post( self::$apiUrl . "?action=login&format=xml",
array( "postData" => array(
}
$resp = Http::post( self::$apiUrl . "?action=login&format=xml",
array( "postData" => array(
}
function testApiLoginBadPass() {
}
function testApiLoginBadPass() {
- global $wgServerName, $wgServer;
- if ( !isset( $wgServerName ) || !isset( $wgServer ) ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( !isset( $wgServer ) ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
$resp = Http::post( self::$apiUrl . "?action=login&format=xml",
array( "postData" => array(
}
$resp = Http::post( self::$apiUrl . "?action=login&format=xml",
array( "postData" => array(
}
function testApiLoginGoodPass() {
}
function testApiLoginGoodPass() {
- global $wgServerName, $wgServer;
- if ( !isset( $wgServerName ) || !isset( $wgServer ) ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( !isset( $wgServer ) ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
$req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
array( "method" => "POST",
}
$req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
array( "method" => "POST",
}
function testApiGotCookie() {
}
function testApiGotCookie() {
- global $wgServerName, $wgServer, $wgScriptPath;
+ global $wgServer, $wgScriptPath;
- if ( !isset( $wgServerName ) || !isset( $wgServer ) ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( !isset( $wgServer ) ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
$req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
array( "method" => "POST",
}
$req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
array( "method" => "POST",
$req->execute();
$cj = $req->getCookieJar();
$req->execute();
$cj = $req->getCookieJar();
- $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName );
+ $serverName = parse_url( $wgServer, PHP_URL_HOST );
+ $this->assertNotEquals( false, $serverName );
+ $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $serverName );
$this->assertNotEquals( '', $serializedCookie );
$this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie );
$this->assertNotEquals( '', $serializedCookie );
$this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie );
*/
function testApiListPages( CookieJar $cj ) {
$this->markTestIncomplete( "Not done with this yet" );
*/
function testApiListPages( CookieJar $cj ) {
$this->markTestIncomplete( "Not done with this yet" );
- global $wgServerName, $wgServer;
- if ( $wgServerName == "localhost" || $wgServer == "http://localhost" ) {
- $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' .
- 'be set in LocalSettings.php' );
+ if ( $wgServer == "http://localhost" ) {
+ $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
}
$req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
"titles=Main%20Page&rvprop=timestamp|user|comment|content" );
}
$req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" .
"titles=Main%20Page&rvprop=timestamp|user|comment|content" );