From: Roan Kattouw Date: Wed, 7 Sep 2011 14:15:03 +0000 (+0000) Subject: Actually fix bug 30792, despite my earlier claims. SquidUpdate::purge('//upload.wikim... X-Git-Tag: 1.31.0-rc.0~27834 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=ee24d7b2892814b1799ce3165a22bbbdf81c07df;p=lhc%2Fweb%2Fwiklou.git Actually fix bug 30792, despite my earlier claims. SquidUpdate::purge('//upload.wikimedia.org/foo') would return 'commons.wikimedia.org//upload.wikimedia.org/foo' Introduce PROTO_INTERNAL much like PROTO_CANONICAL, and use it in SquidUpdate::purge() --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 017b842d41..9431f9c96d 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -438,6 +438,7 @@ function wfAppendQuery( $url, $query ) { * PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL) * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer + * PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer * * @todo this won't work with current-path-relative URLs * like "subdir/foo.html", etc. @@ -447,9 +448,15 @@ function wfAppendQuery( $url, $query ) { * @return string Fully-qualified URL */ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { - global $wgServer, $wgCanonicalServer; - $serverUrl = $defaultProto === PROTO_CANONICAL ? $wgCanonicalServer : $wgServer; - + global $wgServer, $wgCanonicalServer, $wgInternalServer; + $serverUrl = $wgServer; + if ( $defaultProto === PROTO_CANONICAL ) { + $serverUrl = $wgCanonicalServer; + } + // Make $wgInternalServer fall back to $wgServer if not set + if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) { + $serverUrl = $wgInternalServer; + } if ( $defaultProto === PROTO_CURRENT ) { $defaultProto = WebRequest::detectProtocol() . '://'; } @@ -458,11 +465,11 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { $bits = wfParseUrl( $serverUrl ); $serverHasProto = $bits && $bits['scheme'] != ''; - if ( $defaultProto === PROTO_CANONICAL ) { + if ( $defaultProto === PROTO_CANONICAL || $defaultProto === PROTO_INTERNAL ) { if ( $serverHasProto ) { $defaultProto = $bits['scheme'] . '://'; } else { - // $wgCanonicalServer doesn't have a protocol. This really isn't supposed to happen + // $wgCanonicalServer or $wgInternalServer doesn't have a protocol. This really isn't supposed to happen // Fall back to HTTP in this ridiculous case $defaultProto = PROTO_HTTP; } diff --git a/includes/cache/SquidUpdate.php b/includes/cache/SquidUpdate.php index 07ef04acc5..d47b5b5e24 100644 --- a/includes/cache/SquidUpdate.php +++ b/includes/cache/SquidUpdate.php @@ -221,11 +221,6 @@ class SquidUpdate { * @return string */ static function expand( $url ) { - global $wgInternalServer, $wgServer; - $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; - if( $url !== '' && $url[0] == '/' ) { - return $server . $url; - } - return $url; + return wfExpandUrl( $url, PROTO_INTERNAL ); } }