Index: branches/wmf/1.18wmf1/extensions/ExtensionDistributor/ExtensionDistributor_body.php |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | | - $url = "$wgExtDistTarUrl/$tarName"; |
| 253 | + $url = wfExpandUrl( "$wgExtDistTarUrl/$tarName", PROTO_CURRENT ); |
254 | 254 | |
255 | 255 | // Show a message |
256 | 256 | $wgOut->addWikiMsg( 'extdist-created', $extension, "r$rev", |
Index: branches/wmf/1.18wmf1/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -163,7 +163,8 @@ |
164 | 164 | $wgMemc->set( CentralAuthUser::memcKey( 'login-token', $loginToken ), $data, 600 ); |
165 | 165 | |
166 | 166 | $wiki = WikiMap::getWiki( $wiki ); |
167 | | - $url = wfAppendQuery( $wiki->getUrl( 'Special:AutoLogin' ), "token=$loginToken" ); |
| 167 | + // Use WikiReference::getFullUrl(), returns a protocol-relative URL if needed |
| 168 | + $url = wfAppendQuery( $wiki->getFullUrl( 'Special:AutoLogin' ), "token=$loginToken" ); |
168 | 169 | |
169 | 170 | $inject_html .= Xml::element( 'img', |
170 | 171 | array( |
Index: branches/wmf/1.18wmf1/includes/WikiMap.php |
— | — | @@ -18,11 +18,13 @@ |
19 | 19 | |
20 | 20 | list( $major, $minor ) = $wgConf->siteFromDB( $wikiID ); |
21 | 21 | if( isset( $major ) ) { |
22 | | - $server = $wgConf->get( 'wgCanonicalServer', $wikiID, $major, |
| 22 | + $canonicalServer = $wgConf->get( 'wgCanonicalServer', $wikiID, $major, |
23 | 23 | array( 'lang' => $minor, 'site' => $major ) ); |
| 24 | + $server = $wgConf->get( 'wgServer', $wikiID, $major, |
| 25 | + array( 'lang' => $minor, 'site' => $major ) ); |
24 | 26 | $path = $wgConf->get( 'wgArticlePath', $wikiID, $major, |
25 | 27 | array( 'lang' => $minor, 'site' => $major ) ); |
26 | | - return new WikiReference( $major, $minor, $server, $path ); |
| 28 | + return new WikiReference( $major, $minor, $canonicalServer, $path, $server ); |
27 | 29 | } else { |
28 | 30 | return null; |
29 | 31 | } |
— | — | @@ -101,21 +103,23 @@ |
102 | 104 | class WikiReference { |
103 | 105 | private $mMinor; ///< 'en', 'meta', 'mediawiki', etc |
104 | 106 | private $mMajor; ///< 'wiki', 'wiktionary', etc |
105 | | - private $mServer; ///< server override, 'www.mediawiki.org' |
106 | | - private $mPath; ///< path override, '/wiki/$1' |
| 107 | + private $mCanonicalServer; ///< canonical server URL, e.g. 'http://www.mediawiki.org' |
| 108 | + private $mServer; ///< server URL, may be protocol-relative, e.g. '//www.mediawiki.org' |
| 109 | + private $mPath; ///< path, '/wiki/$1' |
107 | 110 | |
108 | | - public function __construct( $major, $minor, $server, $path ) { |
| 111 | + public function __construct( $major, $minor, $canonicalServer, $path, $server = null ) { |
109 | 112 | $this->mMajor = $major; |
110 | 113 | $this->mMinor = $minor; |
111 | | - $this->mServer = $server; |
| 114 | + $this->mCanonicalServer = $canonicalServer; |
112 | 115 | $this->mPath = $path; |
| 116 | + $this->mServer = $server === null ? $canonicalServer : $server; |
113 | 117 | } |
114 | 118 | |
115 | 119 | public function getHostname() { |
116 | 120 | $prefixes = array( 'http://', 'https://' ); |
117 | 121 | foreach ( $prefixes as $prefix ) { |
118 | | - if ( substr( $this->mServer, 0, strlen( $prefix ) ) ) { |
119 | | - return substr( $this->mServer, strlen( $prefix ) ); |
| 122 | + if ( substr( $this->mCanonicalServer, 0, strlen( $prefix ) ) ) { |
| 123 | + return substr( $this->mCanonicalServer, strlen( $prefix ) ); |
120 | 124 | } |
121 | 125 | } |
122 | 126 | throw new MWException( "Invalid hostname for wiki {$this->mMinor}.{$this->mMajor}" ); |
— | — | @@ -150,12 +154,32 @@ |
151 | 155 | } |
152 | 156 | |
153 | 157 | /** |
154 | | - * Get a URL to a page on this foreign wiki |
| 158 | + * Get a canonical (i.e. based on $wgCanonicalServer) URL to a page on this foreign wiki |
155 | 159 | * |
156 | 160 | * @param $page String: page name (must be normalised before calling this function!) |
157 | 161 | * @return String: Url |
158 | 162 | */ |
| 163 | + public function getCanonicalUrl( $page ) { |
| 164 | + return |
| 165 | + $this->mCanonicalServer . |
| 166 | + $this->getLocalUrl( $page ); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Alias for getCanonicalUrl(), for backwards compatibility. |
| 171 | + */ |
159 | 172 | public function getUrl( $page ) { |
| 173 | + return $this->getCanonicalUrl( $page ); |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * Get a URL based on $wgServer, like Title::getFullUrl() would produce |
| 178 | + * when called locally on the wiki. |
| 179 | + * |
| 180 | + * @param $page String: page name (must be normalized before calling this function!) |
| 181 | + * @return String: URL |
| 182 | + */ |
| 183 | + public function getFullUrl( $page ) { |
160 | 184 | return |
161 | 185 | $this->mServer . |
162 | 186 | $this->getLocalUrl( $page ); |