r96437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96436‎ | r96437 | r96438 >
Date:14:15, 7 September 2011
Author:catrope
Status:ok
Tags:
Comment:
Actually fix bug 30792, despite my earlier claims. SquidUpdate::purge('//upload.wikimedia.org/foo') would return 'http://commons.wikimedia.org//upload.wikimedia.org/foo'

Introduce PROTO_INTERNAL much like PROTO_CANONICAL, and use it in SquidUpdate::purge()
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/cache/SquidUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -438,6 +438,7 @@
439439 * PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL)
440440 * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request
441441 * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer
 442+ * PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer
442443 *
443444 * @todo this won't work with current-path-relative URLs
444445 * like "subdir/foo.html", etc.
@@ -447,9 +448,15 @@
448449 * @return string Fully-qualified URL
449450 */
450451 function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
451 - global $wgServer, $wgCanonicalServer;
452 - $serverUrl = $defaultProto === PROTO_CANONICAL ? $wgCanonicalServer : $wgServer;
453 -
 452+ global $wgServer, $wgCanonicalServer, $wgInternalServer;
 453+ $serverUrl = $wgServer;
 454+ if ( $defaultProto === PROTO_CANONICAL ) {
 455+ $serverUrl = $wgCanonicalServer;
 456+ }
 457+ // Make $wgInternalServer fall back to $wgServer if not set
 458+ if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
 459+ $serverUrl = $wgInternalServer;
 460+ }
454461 if ( $defaultProto === PROTO_CURRENT ) {
455462 $defaultProto = WebRequest::detectProtocol() . '://';
456463 }
@@ -458,11 +465,11 @@
459466 $bits = wfParseUrl( $serverUrl );
460467 $serverHasProto = $bits && $bits['scheme'] != '';
461468
462 - if ( $defaultProto === PROTO_CANONICAL ) {
 469+ if ( $defaultProto === PROTO_CANONICAL || $defaultProto === PROTO_INTERNAL ) {
463470 if ( $serverHasProto ) {
464471 $defaultProto = $bits['scheme'] . '://';
465472 } else {
466 - // $wgCanonicalServer doesn't have a protocol. This really isn't supposed to happen
 473+ // $wgCanonicalServer or $wgInternalServer doesn't have a protocol. This really isn't supposed to happen
467474 // Fall back to HTTP in this ridiculous case
468475 $defaultProto = PROTO_HTTP;
469476 }
Index: trunk/phase3/includes/cache/SquidUpdate.php
@@ -221,11 +221,6 @@
222222 * @return string
223223 */
224224 static function expand( $url ) {
225 - global $wgInternalServer, $wgServer;
226 - $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
227 - if( $url !== '' && $url[0] == '/' ) {
228 - return $server . $url;
229 - }
230 - return $url;
 225+ return wfExpandUrl( $url, PROTO_INTERNAL );
231226 }
232227 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r96438Followup r96437: actually define PROTO_INTERNALcatrope14:17, 7 September 2011
r964391.17wmf1: MFT r96437, r96438catrope14:20, 7 September 2011
r990431.18wmf1: MFT r96437, r96438, were merged to 1.17wmf1 but forgotten in 1.18wmf1catrope20:15, 5 October 2011
r99980REL1_18 MFT r93726, r94199, r96437, r96438, r696579, r98235, r98734reedy22:13, 16 October 2011

Status & tagging log