http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98747
Revision: 98747 Author: catrope Date: 2011-10-03 10:42:56 +0000 (Mon, 03 Oct 2011) Log Message: ----------- 1.17wmf1: MFT r98744, r98745 Modified Paths: -------------- branches/wmf/1.17wmf1/extensions/CentralAuth/CentralAuthHooks.php branches/wmf/1.17wmf1/extensions/ExtensionDistributor/ExtensionDistributor_body.php branches/wmf/1.17wmf1/includes/WikiMap.php Modified: branches/wmf/1.17wmf1/extensions/CentralAuth/CentralAuthHooks.php =================================================================== --- branches/wmf/1.17wmf1/extensions/CentralAuth/CentralAuthHooks.php 2011-10-03 10:42:30 UTC (rev 98746) +++ branches/wmf/1.17wmf1/extensions/CentralAuth/CentralAuthHooks.php 2011-10-03 10:42:56 UTC (rev 98747) @@ -137,7 +137,8 @@ $wgMemc->set( CentralAuthUser::memcKey( 'login-token', $loginToken ), $data, 600 ); $wiki = WikiMap::getWiki( $wiki ); - $url = wfAppendQuery( $wiki->getUrl( 'Special:AutoLogin' ), "token=$loginToken" ); + // Use WikiReference::getFullUrl(), returns a protocol-relative URL if needed + $url = wfAppendQuery( $wiki->getFullUrl( 'Special:AutoLogin' ), "token=$loginToken" ); $inject_html .= Xml::element( 'img', array( Modified: branches/wmf/1.17wmf1/extensions/ExtensionDistributor/ExtensionDistributor_body.php =================================================================== --- branches/wmf/1.17wmf1/extensions/ExtensionDistributor/ExtensionDistributor_body.php 2011-10-03 10:42:30 UTC (rev 98746) +++ branches/wmf/1.17wmf1/extensions/ExtensionDistributor/ExtensionDistributor_body.php 2011-10-03 10:42:56 UTC (rev 98747) @@ -249,7 +249,7 @@ } } - $url = "$wgExtDistTarUrl/$tarName"; + $url = wfExpandUrl( "$wgExtDistTarUrl/$tarName", PROTO_CURRENT ); // Show a message $wgOut->addWikiMsg( 'extdist-created', $extension, "r$rev", Modified: branches/wmf/1.17wmf1/includes/WikiMap.php =================================================================== --- branches/wmf/1.17wmf1/includes/WikiMap.php 2011-10-03 10:42:30 UTC (rev 98746) +++ branches/wmf/1.17wmf1/includes/WikiMap.php 2011-10-03 10:42:56 UTC (rev 98747) @@ -18,11 +18,13 @@ list( $major, $minor ) = $wgConf->siteFromDB( $wikiID ); if( isset( $major ) ) { - $server = $wgConf->get( 'wgCanonicalServer', $wikiID, $major, + $canonicalServer = $wgConf->get( 'wgCanonicalServer', $wikiID, $major, array( 'lang' => $minor, 'site' => $major ) ); + $server = $wgConf->get( 'wgServer', $wikiID, $major, + array( 'lang' => $minor, 'site' => $major ) ); $path = $wgConf->get( 'wgArticlePath', $wikiID, $major, array( 'lang' => $minor, 'site' => $major ) ); - return new WikiReference( $major, $minor, $server, $path ); + return new WikiReference( $major, $minor, $canonicalServer, $path, $server ); } else { return null; } @@ -104,21 +106,23 @@ class WikiReference { private $mMinor; ///< 'en', 'meta', 'mediawiki', etc private $mMajor; ///< 'wiki', 'wiktionary', etc - private $mServer; ///< server override, 'www.mediawiki.org' - private $mPath; ///< path override, '/wiki/$1' + private $mCanonicalServer; ///< canonical server URL, e.g. 'http://www.mediawiki.org' + private $mServer; ///< server URL, may be protocol-relative, e.g. '//www.mediawiki.org' + private $mPath; ///< path, '/wiki/$1' - public function __construct( $major, $minor, $server, $path ) { + public function __construct( $major, $minor, $canonicalServer, $path, $server = null ) { $this->mMajor = $major; $this->mMinor = $minor; - $this->mServer = $server; + $this->mCanonicalServer = $canonicalServer; $this->mPath = $path; + $this->mServer = $server === null ? $canonicalServer : $server; } public function getHostname() { $prefixes = array( 'http://', 'https://' ); foreach ( $prefixes as $prefix ) { - if ( substr( $this->mServer, 0, strlen( $prefix ) ) ) { - return substr( $this->mServer, strlen( $prefix ) ); + if ( substr( $this->mCanonicalServer, 0, strlen( $prefix ) ) ) { + return substr( $this->mCanonicalServer, strlen( $prefix ) ); } } throw new MWException( "Invalid hostname for wiki {$this->mMinor}.{$this->mMajor}" ); @@ -153,12 +157,32 @@ } /** - * Get a URL to a page on this foreign wiki + * Get a canonical (i.e. based on $wgCanonicalServer) URL to a page on this foreign wiki * * @param $page String: page name (must be normalised before calling this function!) * @return String: Url */ + public function getCanonicalUrl( $page ) { + return + $this->mCanonicalServer . + $this->getLocalUrl( $page ); + } + + /** + * Alias for getCanonicalUrl(), for backwards compatibility. + */ public function getUrl( $page ) { + return $this->getCanonicalUrl( $page ); + } + + /** + * Get a URL based on $wgServer, like Title::getFullUrl() would produce + * when called locally on the wiki. + * + * @param $page String: page name (must be normalized before calling this function!) + * @return String: URL + */ + public function getFullUrl( $page ) { return $this->mServer . $this->getLocalUrl( $page ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs