r94996 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94995‎ | r94996 | r94997 >
Date:13:25, 19 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Reverse a bad decision in r93820, which added a comment to WebRequest::getFullRequestURL() saying it would return protocol-relative URLs if $wgServer is protocol-relative. This behavior makes no sense, though, and most callers expect fully qualified URLs. So make it return a fully qualified URL and update the one caller that expected the return value would be compatible with getFullURL()
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -603,14 +603,14 @@
604604 * Return the request URI with the canonical service and hostname, path,
605605 * and query string. This will be suitable for use as an absolute link
606606 * in HTML or other output.
 607+ *
 608+ * If $wgServer is protocol-relative, this will return a fully
 609+ * qualified URL with the protocol that was used for this request.
607610 *
608 - * NOTE: This will output a protocol-relative URL if $wgServer is protocol-relative
609 - *
610611 * @return String
611612 */
612613 public function getFullRequestURL() {
613 - global $wgServer;
614 - return $wgServer . $this->getRequestURL();
 614+ return wfExpandUrl( $this->getRequestURL(), PROTO_CURRENT );
615615 }
616616
617617 /**
Index: trunk/phase3/includes/Wiki.php
@@ -187,7 +187,7 @@
188188 $title = SpecialPage::getTitleFor( $name, $subpage );
189189 }
190190 }
191 - $targetUrl = $title->getFullURL();
 191+ $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
192192 // Redirect to canonical url, make it a 301 to allow caching
193193 if ( $targetUrl == $request->getFullRequestURL() ) {
194194 $message = "Redirect loop detected!\n\n" .

Follow-up revisions

RevisionCommit summaryAuthorDate
r955051.17wmf1: Merge a truckload of HTTPS / prot rel URL fixes: r93847, r94990, r9...catrope19:32, 25 August 2011
r95607MFT to REL1_18...hashar19:28, 27 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93820Some random URL protocol forcing for protocol-relative URLscatrope12:58, 3 August 2011

Status & tagging log