From: Roan Kattouw Date: Fri, 19 Aug 2011 08:56:39 +0000 (+0000) Subject: Followup r94754: move protocol expansion from getIRCLine() to inside getInternalUrl... X-Git-Tag: 1.31.0-rc.0~28178 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=3b35a3d2eceac76a41fde4f219546024962df3c2;p=lhc%2Fweb%2Fwiklou.git Followup r94754: move protocol expansion from getIRCLine() to inside getInternalUrl(); these internal URLs should always be fully qualified. Effectively this means that if $wgServer is protocol-relative and $wgInternalServer either isn't set or is also protocol relative (but it really shouldn't be the latter!), we'll add to URLs used for Squid purging and in IRC lines. If people want those to be https:// instead, they can set $wgInternalServer accordingly. We should really, really break the connection between internal URLs used for Squid purges and URLs used for IRC, and use the latter in e-mails as well. This was briefly discussed in the CR comments on r44412 and I'll be working on that today. --- diff --git a/includes/RecentChange.php b/includes/RecentChange.php index a3deb91a10..b01368c7c2 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -707,9 +707,7 @@ class RecentChange { // XXX: *HACK^2* the preg_replace() undoes much of what getInternalURL() does, but we // XXX: need to call it so that URL paths on the Wikimedia secure server can be fixed // XXX: by a custom GetInternalURL hook --vyznev 2008-12-10 - // XXX: Also, getInternalUrl() may return a protocol-relative URL. - // XXX: In that case, expand it to an HTTP URL, even if this is an HTTPS request --catrope 2011-08-17 - $url = preg_replace( '/title=[^&]*&/', '', wfExpandUrl( $titleObj->getInternalURL( $url ), PROTO_HTTP ) ); + $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) ); } if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) { diff --git a/includes/Title.php b/includes/Title.php index 29f292e828..fab3b5bea9 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -992,6 +992,10 @@ class Title { * Get the URL form for an internal link. * - Used in various Squid-related code, in case we have a different * internal hostname for the server from the exposed one. + * + * This uses $wgInternalServer to qualify the path, or $wgServer + * if $wgInternalServer is not set. If the server variable used is + * protocol-relative, the URL will be expanded to http:// * * @param $query String an optional query string * @param $variant String language variant of url (for sr, zh..) @@ -1000,7 +1004,7 @@ class Title { public function getInternalURL( $query = '', $variant = false ) { global $wgInternalServer, $wgServer; $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; - $url = $server . $this->getLocalURL( $query, $variant ); + $url = wfExpandUrl( $server . $this->getLocalURL( $query, $variant ), PROTO_HTTP ); wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); return $url; }