Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php |
— | — | @@ -54,11 +54,10 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | function testApi() { |
58 | | - global $wgServerName, $wgServer; |
| 58 | + global $wgServer; |
59 | 59 | |
60 | | - if ( !isset( $wgServerName ) || !isset( $wgServer ) ) { |
61 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
62 | | - 'be set in LocalSettings.php' ); |
| 60 | + if ( !isset( $wgServer ) ) { |
| 61 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
63 | 62 | } |
64 | 63 | /* Haven't thought about test ordering yet -- but this depends on HttpTest.php */ |
65 | 64 | $resp = Http::get( self::$apiUrl . "?format=xml" ); |
— | — | @@ -70,11 +69,10 @@ |
71 | 70 | } |
72 | 71 | |
73 | 72 | function testApiLoginNoName() { |
74 | | - global $wgServerName, $wgServer; |
| 73 | + global $wgServer; |
75 | 74 | |
76 | | - if ( !isset( $wgServerName ) || !isset( $wgServer ) ) { |
77 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
78 | | - 'be set in LocalSettings.php' ); |
| 75 | + if ( !isset( $wgServer ) ) { |
| 76 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
79 | 77 | } |
80 | 78 | $resp = Http::post( self::$apiUrl . "?action=login&format=xml", |
81 | 79 | array( "postData" => array( |
— | — | @@ -89,11 +87,10 @@ |
90 | 88 | } |
91 | 89 | |
92 | 90 | function testApiLoginBadPass() { |
93 | | - global $wgServerName, $wgServer; |
| 91 | + global $wgServer; |
94 | 92 | |
95 | | - if ( !isset( $wgServerName ) || !isset( $wgServer ) ) { |
96 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
97 | | - 'be set in LocalSettings.php' ); |
| 93 | + if ( !isset( $wgServer ) ) { |
| 94 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
98 | 95 | } |
99 | 96 | $resp = Http::post( self::$apiUrl . "?action=login&format=xml", |
100 | 97 | array( "postData" => array( |
— | — | @@ -124,11 +121,10 @@ |
125 | 122 | } |
126 | 123 | |
127 | 124 | function testApiLoginGoodPass() { |
128 | | - global $wgServerName, $wgServer; |
| 125 | + global $wgServer; |
129 | 126 | |
130 | | - if ( !isset( $wgServerName ) || !isset( $wgServer ) ) { |
131 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
132 | | - 'be set in LocalSettings.php' ); |
| 127 | + if ( !isset( $wgServer ) ) { |
| 128 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
133 | 129 | } |
134 | 130 | $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml", |
135 | 131 | array( "method" => "POST", |
— | — | @@ -163,11 +159,10 @@ |
164 | 160 | } |
165 | 161 | |
166 | 162 | function testApiGotCookie() { |
167 | | - global $wgServerName, $wgServer, $wgScriptPath; |
| 163 | + global $wgServer, $wgScriptPath; |
168 | 164 | |
169 | | - if ( !isset( $wgServerName ) || !isset( $wgServer ) ) { |
170 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
171 | | - 'be set in LocalSettings.php' ); |
| 165 | + if ( !isset( $wgServer ) ) { |
| 166 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
172 | 167 | } |
173 | 168 | $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml", |
174 | 169 | array( "method" => "POST", |
— | — | @@ -193,7 +188,9 @@ |
194 | 189 | $req->execute(); |
195 | 190 | |
196 | 191 | $cj = $req->getCookieJar(); |
197 | | - $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName ); |
| 192 | + $serverName = parse_url( $wgServer, PHP_URL_HOST ); |
| 193 | + $this->assertNotEquals( false, $serverName ); |
| 194 | + $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $serverName ); |
198 | 195 | $this->assertNotEquals( '', $serializedCookie ); |
199 | 196 | $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie ); |
200 | 197 | |
— | — | @@ -206,11 +203,10 @@ |
207 | 204 | */ |
208 | 205 | function testApiListPages( CookieJar $cj ) { |
209 | 206 | $this->markTestIncomplete( "Not done with this yet" ); |
210 | | - global $wgServerName, $wgServer; |
| 207 | + global $wgServer; |
211 | 208 | |
212 | | - if ( $wgServerName == "localhost" || $wgServer == "http://localhost" ) { |
213 | | - $this->markTestIncomplete( 'This test needs $wgServerName and $wgServer to ' . |
214 | | - 'be set in LocalSettings.php' ); |
| 209 | + if ( $wgServer == "http://localhost" ) { |
| 210 | + $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); |
215 | 211 | } |
216 | 212 | $req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&" . |
217 | 213 | "titles=Main%20Page&rvprop=timestamp|user|comment|content" ); |
Index: trunk/phase3/maintenance/tests/parser/parserTest.inc |
— | — | @@ -532,7 +532,7 @@ |
533 | 533 | self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 ); |
534 | 534 | |
535 | 535 | $settings = array( |
536 | | - 'wgServer' => 'http://localhost', |
| 536 | + 'wgServer' => 'http://Britney-Spears', |
537 | 537 | 'wgScript' => '/index.php', |
538 | 538 | 'wgScriptPath' => '/', |
539 | 539 | 'wgArticlePath' => '/wiki/$1', |
— | — | @@ -549,7 +549,6 @@ |
550 | 550 | 'wgStylePath' => '/skins', |
551 | 551 | 'wgStyleSheetPath' => '/skins', |
552 | 552 | 'wgSitename' => 'MediaWiki', |
553 | | - 'wgServerName' => 'Britney-Spears', |
554 | 553 | 'wgLanguageCode' => $lang, |
555 | 554 | 'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_', |
556 | 555 | 'wgRawHtml' => isset( $opts['rawhtml'] ), |
Index: trunk/phase3/maintenance/tests/parser/parserTests.txt |
— | — | @@ -2090,7 +2090,7 @@ |
2091 | 2091 | !! input |
2092 | 2092 | {{SERVER}} |
2093 | 2093 | !! result |
2094 | | -<p><a href="http://localhost" class="external free" rel="nofollow">http://localhost</a> |
| 2094 | +<p><a href="http://Britney-Spears" class="external free" rel="nofollow">http://Britney-Spears</a> |
2095 | 2095 | </p> |
2096 | 2096 | !! end |
2097 | 2097 | |
Index: trunk/phase3/docs/distributors.txt |
— | — | @@ -96,9 +96,10 @@ |
97 | 97 | intelligently: |
98 | 98 | |
99 | 99 | * $wgEmergencyContact: An e-mail address that can be used to contact the wiki |
100 | | - administrator. By default, "wikiadmin@$wgServerName". |
| 100 | + administrator. By default, "wikiadmin@ServerName". |
101 | 101 | * $wgPasswordSender: The e-mail address to use when sending password e-mails. |
102 | | - By default, "MediaWiki Mail <apache@$wgServerName>". |
| 102 | + By default, "MediaWiki Mail <apache@ServerName>". |
| 103 | + (with ServerName guessed from the http request) |
103 | 104 | * $wgSMTP: Can be configured to use SMTP for mail sending instead of PHP |
104 | 105 | mail(). |
105 | 106 | |
Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -2495,7 +2495,7 @@ |
2496 | 2496 | * @private |
2497 | 2497 | */ |
2498 | 2498 | function getVariableValue( $index, $frame=false ) { |
2499 | | - global $wgContLang, $wgSitename, $wgServer, $wgServerName; |
| 2499 | + global $wgContLang, $wgSitename, $wgServer; |
2500 | 2500 | global $wgArticlePath, $wgScriptPath, $wgStylePath; |
2501 | 2501 | |
2502 | 2502 | /** |
— | — | @@ -2777,7 +2777,10 @@ |
2778 | 2778 | case 'server': |
2779 | 2779 | return $wgServer; |
2780 | 2780 | case 'servername': |
2781 | | - return $wgServerName; |
| 2781 | + wfSuppressWarnings(); # May give an E_WARNING in PHP < 5.3.3 |
| 2782 | + $serverName = parse_url( $wgServer, PHP_URL_HOST ); |
| 2783 | + wfRestoreWarnings(); |
| 2784 | + return $serverName ? $serverName : $wgServer; |
2782 | 2785 | case 'scriptpath': |
2783 | 2786 | return $wgScriptPath; |
2784 | 2787 | case 'stylepath': |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -56,23 +56,23 @@ |
57 | 57 | |
58 | 58 | /** @cond file_level_code */ |
59 | 59 | if( isset( $_SERVER['SERVER_NAME'] ) ) { |
60 | | - $wgServerName = $_SERVER['SERVER_NAME']; |
| 60 | + $serverName = $_SERVER['SERVER_NAME']; |
61 | 61 | } elseif( isset( $_SERVER['HOSTNAME'] ) ) { |
62 | | - $wgServerName = $_SERVER['HOSTNAME']; |
| 62 | + $serverName = $_SERVER['HOSTNAME']; |
63 | 63 | } elseif( isset( $_SERVER['HTTP_HOST'] ) ) { |
64 | | - $wgServerName = $_SERVER['HTTP_HOST']; |
| 64 | + $serverName = $_SERVER['HTTP_HOST']; |
65 | 65 | } elseif( isset( $_SERVER['SERVER_ADDR'] ) ) { |
66 | | - $wgServerName = $_SERVER['SERVER_ADDR']; |
| 66 | + $serverName = $_SERVER['SERVER_ADDR']; |
67 | 67 | } else { |
68 | | - $wgServerName = 'localhost'; |
| 68 | + $serverName = 'localhost'; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; |
72 | 72 | |
73 | | -$wgServer = $wgProto.'://' . $wgServerName; |
| 73 | +$wgServer = $wgProto.'://' . $serverName; |
74 | 74 | # If the port is a non-standard one, add it to the URL |
75 | 75 | if( isset( $_SERVER['SERVER_PORT'] ) |
76 | | - && !strpos( $wgServerName, ':' ) |
| 76 | + && !strpos( $serverName, ':' ) |
77 | 77 | && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 ) |
78 | 78 | || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { |
79 | 79 | |
— | — | @@ -968,15 +968,17 @@ |
969 | 969 | /** |
970 | 970 | * Site admin email address. |
971 | 971 | */ |
972 | | -$wgEmergencyContact = 'wikiadmin@' . $wgServerName; |
| 972 | +$wgEmergencyContact = 'wikiadmin@' . $serverName; |
973 | 973 | |
974 | 974 | /** |
975 | 975 | * Password reminder email address. |
976 | 976 | * |
977 | 977 | * The address we should use as sender when a user is requesting his password. |
978 | 978 | */ |
979 | | -$wgPasswordSender = 'MediaWiki Mail <apache@' . $wgServerName . '>'; |
| 979 | +$wgPasswordSender = 'MediaWiki Mail <apache@' . $serverName . '>'; |
980 | 980 | |
| 981 | +unset($serverName); # Don't leak local variables to global scope |
| 982 | + |
981 | 983 | /** |
982 | 984 | * Dummy address which should be accepted during mail send action. |
983 | 985 | * It might be necessary to adapt the address or to set it equal |