r99043 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99042‎ | r99043 | r99044 >
Date:20:15, 5 October 2011
Author:catrope
Status:ok
Tags:
Comment:
1.18wmf1: MFT r96437, r96438, were merged to 1.17wmf1 but forgotten in 1.18wmf1
Modified paths:
  • /branches/wmf/1.18wmf1/includes/Defines.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/GlobalFunctions.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/cache/SquidUpdate.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/includes/Defines.php
@@ -249,3 +249,4 @@
250250 define( 'PROTO_RELATIVE', '//' );
251251 define( 'PROTO_CURRENT', null );
252252 define( 'PROTO_CANONICAL', 1 );
 253+define( 'PROTO_INTERNAL', 2 );
Property changes on: branches/wmf/1.18wmf1/includes/Defines.php
___________________________________________________________________
Added: svn:mergeinfo
253254 Merged /trunk/phase3/includes/Defines.php:r93438,96437-96438
Index: branches/wmf/1.18wmf1/includes/GlobalFunctions.php
@@ -433,6 +433,7 @@
434434 * PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL)
435435 * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request
436436 * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer
 437+ * PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer
437438 *
438439 * @todo this won't work with current-path-relative URLs
439440 * like "subdir/foo.html", etc.
@@ -442,9 +443,15 @@
443444 * @return string Fully-qualified URL
444445 */
445446 function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
446 - global $wgServer, $wgCanonicalServer;
447 - $serverUrl = $defaultProto === PROTO_CANONICAL ? $wgCanonicalServer : $wgServer;
448 -
 447+ global $wgServer, $wgCanonicalServer, $wgInternalServer;
 448+ $serverUrl = $wgServer;
 449+ if ( $defaultProto === PROTO_CANONICAL ) {
 450+ $serverUrl = $wgCanonicalServer;
 451+ }
 452+ // Make $wgInternalServer fall back to $wgServer if not set
 453+ if ( $defaultProto === PROTO_INTERNAL && $wgInternalServer !== false ) {
 454+ $serverUrl = $wgInternalServer;
 455+ }
449456 if ( $defaultProto === PROTO_CURRENT ) {
450457 $defaultProto = WebRequest::detectProtocol() . '://';
451458 }
@@ -453,11 +460,11 @@
454461 $bits = wfParseUrl( $serverUrl );
455462 $serverHasProto = $bits && $bits['scheme'] != '';
456463
457 - if ( $defaultProto === PROTO_CANONICAL ) {
 464+ if ( $defaultProto === PROTO_CANONICAL || $defaultProto === PROTO_INTERNAL ) {
458465 if ( $serverHasProto ) {
459466 $defaultProto = $bits['scheme'] . '://';
460467 } else {
461 - // $wgCanonicalServer doesn't have a protocol. This really isn't supposed to happen
 468+ // $wgCanonicalServer or $wgInternalServer doesn't have a protocol. This really isn't supposed to happen
462469 // Fall back to HTTP in this ridiculous case
463470 $defaultProto = PROTO_HTTP;
464471 }
Property changes on: branches/wmf/1.18wmf1/includes/GlobalFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
465472 Merged /trunk/phase3/includes/GlobalFunctions.php:r93438,96437
Index: branches/wmf/1.18wmf1/includes/cache/SquidUpdate.php
@@ -235,11 +235,6 @@
236236 * @return string
237237 */
238238 static function expand( $url ) {
239 - global $wgInternalServer, $wgServer;
240 - $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
241 - if( $url !== '' && $url[0] == '/' ) {
242 - return $server . $url;
243 - }
244 - return $url;
 239+ return wfExpandUrl( $url, PROTO_INTERNAL );
245240 }
246241 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96437Actually fix bug 30792, despite my earlier claims. SquidUpdate::purge('//uplo...catrope14:15, 7 September 2011
r96438Followup r96437: actually define PROTO_INTERNALcatrope14:17, 7 September 2011

Status & tagging log