/** @cond file_level_code */
if( isset( $_SERVER['SERVER_NAME'] ) ) {
- $wgServerName = $_SERVER['SERVER_NAME'];
+ $serverName = $_SERVER['SERVER_NAME'];
} elseif( isset( $_SERVER['HOSTNAME'] ) ) {
- $wgServerName = $_SERVER['HOSTNAME'];
+ $serverName = $_SERVER['HOSTNAME'];
} elseif( isset( $_SERVER['HTTP_HOST'] ) ) {
- $wgServerName = $_SERVER['HTTP_HOST'];
+ $serverName = $_SERVER['HTTP_HOST'];
} elseif( isset( $_SERVER['SERVER_ADDR'] ) ) {
- $wgServerName = $_SERVER['SERVER_ADDR'];
+ $serverName = $_SERVER['SERVER_ADDR'];
} else {
- $wgServerName = 'localhost';
+ $serverName = 'localhost';
}
$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'] )
- && !strpos( $wgServerName, ':' )
+ && !strpos( $serverName, ':' )
&& ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 )
|| ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) {
/**
* 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.
*/
-$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.
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$settings = array(
- 'wgServer' => 'http://localhost',
+ 'wgServer' => 'http://Britney-Spears',
'wgScript' => '/index.php',
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
'wgStylePath' => '/skins',
'wgStyleSheetPath' => '/skins',
'wgSitename' => 'MediaWiki',
- 'wgServerName' => 'Britney-Spears',
'wgLanguageCode' => $lang,
'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
'wgRawHtml' => isset( $opts['rawhtml'] ),
}
function testApi() {
- global $wgServerName, $wgServer;
+ global $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" );
}
function testApiLoginNoName() {
- global $wgServerName, $wgServer;
+ global $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(
}
function testApiLoginBadPass() {
- global $wgServerName, $wgServer;
+ global $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(
}
function testApiLoginGoodPass() {
- global $wgServerName, $wgServer;
+ global $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",
}
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->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 );
*/
function testApiListPages( CookieJar $cj ) {
$this->markTestIncomplete( "Not done with this yet" );
- global $wgServerName, $wgServer;
+ global $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" );