Remove $wgServerName. Its only usage was for {{servername}}, and needed to be kept in sync with $wgServer in LocalSettings.
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 )).
This commit is contained in:
parent
9f48e9e965
commit
3d408e8d5b
6 changed files with 42 additions and 41 deletions
|
|
@ -96,9 +96,10 @@ Some configuration options that distributors might be in a position to set
|
|||
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.
|
||||
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().
|
||||
|
||||
|
|
|
|||
|
|
@ -56,23 +56,23 @@ $wgServer = '';
|
|||
|
||||
/** @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 ) ) ) {
|
||||
|
||||
|
|
@ -968,14 +968,16 @@ $wgDjvuOutputExtension = 'jpg';
|
|||
/**
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -2495,7 +2495,7 @@ class Parser {
|
|||
* @private
|
||||
*/
|
||||
function getVariableValue( $index, $frame=false ) {
|
||||
global $wgContLang, $wgSitename, $wgServer, $wgServerName;
|
||||
global $wgContLang, $wgSitename, $wgServer;
|
||||
global $wgArticlePath, $wgScriptPath, $wgStylePath;
|
||||
|
||||
/**
|
||||
|
|
@ -2777,7 +2777,10 @@ class Parser {
|
|||
case 'server':
|
||||
return $wgServer;
|
||||
case 'servername':
|
||||
return $wgServerName;
|
||||
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':
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ class ParserTest {
|
|||
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
|
||||
|
||||
$settings = array(
|
||||
'wgServer' => 'http://localhost',
|
||||
'wgServer' => 'http://Britney-Spears',
|
||||
'wgScript' => '/index.php',
|
||||
'wgScriptPath' => '/',
|
||||
'wgArticlePath' => '/wiki/$1',
|
||||
|
|
@ -549,7 +549,6 @@ class ParserTest {
|
|||
'wgStylePath' => '/skins',
|
||||
'wgStyleSheetPath' => '/skins',
|
||||
'wgSitename' => 'MediaWiki',
|
||||
'wgServerName' => 'Britney-Spears',
|
||||
'wgLanguageCode' => $lang,
|
||||
'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
|
||||
'wgRawHtml' => isset( $opts['rawhtml'] ),
|
||||
|
|
|
|||
|
|
@ -2090,7 +2090,7 @@ Magic Word: {{SERVER}}
|
|||
!! 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>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
|
|
|
|||
|
|
@ -54,11 +54,10 @@ class ApiTest extends ApiTestSetup {
|
|||
}
|
||||
|
||||
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" );
|
||||
|
|
@ -70,11 +69,10 @@ class ApiTest extends ApiTestSetup {
|
|||
}
|
||||
|
||||
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(
|
||||
|
|
@ -89,11 +87,10 @@ class ApiTest extends ApiTestSetup {
|
|||
}
|
||||
|
||||
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(
|
||||
|
|
@ -124,11 +121,10 @@ class ApiTest extends ApiTestSetup {
|
|||
}
|
||||
|
||||
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",
|
||||
|
|
@ -163,11 +159,10 @@ class ApiTest extends ApiTestSetup {
|
|||
}
|
||||
|
||||
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",
|
||||
|
|
@ -193,7 +188,9 @@ class ApiTest extends ApiTestSetup {
|
|||
$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 );
|
||||
|
||||
|
|
@ -206,11 +203,10 @@ class ApiTest extends ApiTestSetup {
|
|||
*/
|
||||
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" );
|
||||
|
|
|
|||
Loading…
Reference in a new issue