Index: branches/wmf/1.17wmf1/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.17wmf1/extensions/CentralAuth/CentralAuthHooks.php |
— | — | @@ -137,7 +137,8 @@ |
138 | 138 | $wgMemc->set( CentralAuthUser::memcKey( 'login-token', $loginToken ), $data, 600 ); |
139 | 139 | |
140 | 140 | $wiki = WikiMap::getWiki( $wiki ); |
141 | | - $url = wfAppendQuery( $wiki->getUrl( 'Special:AutoLogin' ), "token=$loginToken" ); |
| 141 | + // Use WikiReference::getFullUrl(), returns a protocol-relative URL if needed |
| 142 | + $url = wfAppendQuery( $wiki->getFullUrl( 'Special:AutoLogin' ), "token=$loginToken" ); |
142 | 143 | |
143 | 144 | $inject_html .= Xml::element( 'img', |
144 | 145 | array( |
Index: branches/wmf/1.17wmf1/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 | } |
— | — | @@ -104,21 +106,23 @@ |
105 | 107 | class WikiReference { |
106 | 108 | private $mMinor; ///< 'en', 'meta', 'mediawiki', etc |
107 | 109 | private $mMajor; ///< 'wiki', 'wiktionary', etc |
108 | | - private $mServer; ///< server override, 'www.mediawiki.org' |
109 | | - private $mPath; ///< path override, '/wiki/$1' |
| 110 | + private $mCanonicalServer; ///< canonical server URL, e.g. 'http://www.mediawiki.org' |
| 111 | + private $mServer; ///< server URL, may be protocol-relative, e.g. '//www.mediawiki.org' |
| 112 | + private $mPath; ///< path, '/wiki/$1' |
110 | 113 | |
111 | | - public function __construct( $major, $minor, $server, $path ) { |
| 114 | + public function __construct( $major, $minor, $canonicalServer, $path, $server = null ) { |
112 | 115 | $this->mMajor = $major; |
113 | 116 | $this->mMinor = $minor; |
114 | | - $this->mServer = $server; |
| 117 | + $this->mCanonicalServer = $canonicalServer; |
115 | 118 | $this->mPath = $path; |
| 119 | + $this->mServer = $server === null ? $canonicalServer : $server; |
116 | 120 | } |
117 | 121 | |
118 | 122 | public function getHostname() { |
119 | 123 | $prefixes = array( 'http://', 'https://' ); |
120 | 124 | foreach ( $prefixes as $prefix ) { |
121 | | - if ( substr( $this->mServer, 0, strlen( $prefix ) ) ) { |
122 | | - return substr( $this->mServer, strlen( $prefix ) ); |
| 125 | + if ( substr( $this->mCanonicalServer, 0, strlen( $prefix ) ) ) { |
| 126 | + return substr( $this->mCanonicalServer, strlen( $prefix ) ); |
123 | 127 | } |
124 | 128 | } |
125 | 129 | throw new MWException( "Invalid hostname for wiki {$this->mMinor}.{$this->mMajor}" ); |
— | — | @@ -153,12 +157,32 @@ |
154 | 158 | } |
155 | 159 | |
156 | 160 | /** |
157 | | - * Get a URL to a page on this foreign wiki |
| 161 | + * Get a canonical (i.e. based on $wgCanonicalServer) URL to a page on this foreign wiki |
158 | 162 | * |
159 | 163 | * @param $page String: page name (must be normalised before calling this function!) |
160 | 164 | * @return String: Url |
161 | 165 | */ |
| 166 | + public function getCanonicalUrl( $page ) { |
| 167 | + return |
| 168 | + $this->mCanonicalServer . |
| 169 | + $this->getLocalUrl( $page ); |
| 170 | + } |
| 171 | + |
| 172 | + /** |
| 173 | + * Alias for getCanonicalUrl(), for backwards compatibility. |
| 174 | + */ |
162 | 175 | public function getUrl( $page ) { |
| 176 | + return $this->getCanonicalUrl( $page ); |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * Get a URL based on $wgServer, like Title::getFullUrl() would produce |
| 181 | + * when called locally on the wiki. |
| 182 | + * |
| 183 | + * @param $page String: page name (must be normalized before calling this function!) |
| 184 | + * @return String: URL |
| 185 | + */ |
| 186 | + public function getFullUrl( $page ) { |
163 | 187 | return |
164 | 188 | $this->mServer . |
165 | 189 | $this->getLocalUrl( $page ); |