r96475 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96474‎ | r96475 | r96476 >
Date:19:37, 7 September 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_18/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Defines.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Export.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Feed.php (modified) (history)
  • /branches/REL1_18/phase3/includes/FileDeleteForm.php (modified) (history)
  • /branches/REL1_18/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_18/phase3/includes/OutputPage.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_18/phase3/includes/User.php (modified) (history)
  • /branches/REL1_18/phase3/includes/UserMailer.php (modified) (history)
  • /branches/REL1_18/phase3/includes/actions/RevertAction.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiParse.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQuery.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryIWLinks.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryInfo.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiRsd.php (modified) (history)
  • /branches/REL1_18/phase3/includes/filerepo/File.php (modified) (history)
  • /branches/REL1_18/phase3/includes/search/SearchEngine.php (modified) (history)
  • /branches/REL1_18/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /branches/REL1_18/phase3/opensearch_desc.php (modified) (history)
  • /branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php
@@ -5,11 +5,13 @@
66
77 class wfExpandUrl extends MediaWikiTestCase {
88 /** @dataProvider provideExpandableUrls */
9 - public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $httpsMode, $message ) {
10 - // Fake $wgServer
11 - global $wgServer;
 9+ public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $canServer, $httpsMode, $message ) {
 10+ // Fake $wgServer and $wgCanonicalServer
 11+ global $wgServer, $wgCanonicalServer;
1212 $oldServer = $wgServer;
 13+ $oldCanServer = $wgCanonicalServer;
1314 $wgServer = $server;
 15+ $wgCanonicalServer = $canServer;
1416
1517 // Fake $_SERVER['HTTPS'] if needed
1618 if ( $httpsMode ) {
@@ -20,8 +22,9 @@
2123
2224 $this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message );
2325
24 - // Restore $wgServer
 26+ // Restore $wgServer and $wgCanonicalServer
2527 $wgServer = $oldServer;
 28+ $wgCanonicalServer = $oldCanServer;
2629 }
2730
2831 /**
@@ -30,32 +33,43 @@
3134 public function provideExpandableUrls() {
3235 $modes = array( 'http', 'https' );
3336 $servers = array( 'http' => 'http://example.com', 'https' => 'https://example.com', 'protocol-relative' => '//example.com' );
34 - $defaultProtos = array( 'http' => PROTO_HTTP, 'https' => PROTO_HTTPS, 'protocol-relative' => PROTO_RELATIVE, 'current' => PROTO_CURRENT );
 37+ $defaultProtos = array( 'http' => PROTO_HTTP, 'https' => PROTO_HTTPS, 'protocol-relative' => PROTO_RELATIVE, 'current' => PROTO_CURRENT, 'canonical' => PROTO_CANONICAL );
3538
3639 $retval = array();
3740 foreach ( $modes as $mode ) {
3841 $httpsMode = $mode == 'https';
3942 foreach ( $servers as $serverDesc => $server ) {
40 - foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
41 - $retval[] = array( 'http://example.com', 'http://example.com', $defaultProto, $server, $httpsMode, "Testing fully qualified http URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" );
42 - $retval[] = array( 'https://example.com', 'https://example.com', $defaultProto, $server, $httpsMode, "Testing fully qualified https URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" );
43 - # Would be nice to support this, see fixme on wfExpandUrl()
44 - $retval[] = array( "wiki/FooBar", 'wiki/FooBar', $defaultProto, $server, $httpsMode, "Test non-expandable relative URLs (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" );
45 -
46 - // Determine expected protocol
47 - $p = $protoDesc . ':'; // default case
48 - if ( $protoDesc == 'protocol-relative' ) {
49 - $p = '';
50 - } else if ( $protoDesc == 'current' ) {
51 - $p = "$mode:";
52 - } else {
53 - $p = $protoDesc . ':';
 43+ foreach ( $modes as $canServerMode ) {
 44+ $canServer = "$canServerMode://example2.com";
 45+ foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
 46+ $retval[] = array( 'http://example.com', 'http://example.com', $defaultProto, $server, $canServer, $httpsMode, "Testing fully qualified http URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" );
 47+ $retval[] = array( 'https://example.com', 'https://example.com', $defaultProto, $server, $canServer, $httpsMode, "Testing fully qualified https URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" );
 48+ # Would be nice to support this, see fixme on wfExpandUrl()
 49+ $retval[] = array( "wiki/FooBar", 'wiki/FooBar', $defaultProto, $server, $canServer, $httpsMode, "Test non-expandable relative URLs (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" );
 50+
 51+ // Determine expected protocol
 52+ $p = $protoDesc . ':'; // default case
 53+ if ( $protoDesc == 'protocol-relative' ) {
 54+ $p = '';
 55+ } else if ( $protoDesc == 'current' ) {
 56+ $p = "$mode:";
 57+ } else if ( $protoDesc == 'canonical' ) {
 58+ $p = "$canServerMode:";
 59+ } else {
 60+ $p = $protoDesc . ':';
 61+ }
 62+ // Determine expected server name
 63+ if ( $protoDesc == 'canonical' ) {
 64+ $srv = $canServer;
 65+ } else if ( $serverDesc == 'protocol-relative' ) {
 66+ $srv = $p . $server;
 67+ } else {
 68+ $srv = $server;
 69+ }
 70+
 71+ $retval[] = array( "$p//wikipedia.org", '//wikipedia.org', $defaultProto, $server, $canServer, $httpsMode, "Test protocol-relative URL (defaultProto: $protoDesc, wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" );
 72+ $retval[] = array( "$srv/wiki/FooBar", '/wiki/FooBar', $defaultProto, $server, $canServer, $httpsMode, "Testing expanding URL beginning with / (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" );
5473 }
55 - // Determine expected server name
56 - $srv = $serverDesc == 'protocol-relative' ? $p . $server : $server;
57 -
58 - $retval[] = array( "$p//wikipedia.org", '//wikipedia.org', $defaultProto, $server, $httpsMode, "Test protocol-relative URL (defaultProto: $protoDesc, wgServer: $server, current request protocol: $mode )" );
59 - $retval[] = array( "$srv/wiki/FooBar", '/wiki/FooBar', $defaultProto, $server, $httpsMode, "Testing expanding URL beginning with / (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" );
6074 }
6175 }
6276 }
Property changes on: branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php
___________________________________________________________________
Added: svn:mergeinfo
6377 Merged /branches/sqlite/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r58211-58321
6478 Merged /trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812
6579 Merged /trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php:r95006
6680 Merged /branches/new-installer/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r43664-66004
6781 Merged /branches/REL1_15/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r51646
6882 Merged /branches/REL1_17/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r81445,81448
Index: branches/REL1_18/phase3/includes/Defines.php
@@ -248,4 +248,4 @@
249249 define( 'PROTO_HTTPS', 'https://' );
250250 define( 'PROTO_RELATIVE', '//' );
251251 define( 'PROTO_CURRENT', null );
252 -
 252+define( 'PROTO_CANONICAL', 1 );
Index: branches/REL1_18/phase3/includes/User.php
@@ -3278,7 +3278,7 @@
32793279
32803280 /**
32813281 * Internal function to format the e-mail validation/invalidation URLs.
3282 - * This uses $wgArticlePath directly as a quickie hack to use the
 3282+ * This uses a quickie hack to use the
32833283 * hardcoded English names of the Special: pages, for ASCII safety.
32843284 *
32853285 * @note Since these URLs get dropped directly into emails, using the
@@ -3291,14 +3291,9 @@
32923292 * @return String Formatted URL
32933293 */
32943294 protected function getTokenUrl( $page, $token ) {
3295 - global $wgArticlePath;
3296 - return wfExpandUrl(
3297 - str_replace(
3298 - '$1',
3299 - "Special:$page/$token",
3300 - $wgArticlePath ),
3301 - PROTO_HTTP
3302 - );
 3295+ // Hack to bypass localization of 'Special:'
 3296+ $title = Title::makeTitle( NS_MAIN, "Special:$page/$token" );
 3297+ return $title->getCanonicalUrl();
33033298 }
33043299
33053300 /**
Index: branches/REL1_18/phase3/includes/search/SearchEngine.php
@@ -472,7 +472,7 @@
473473 * @return String
474474 */
475475 public static function getOpenSearchTemplate() {
476 - global $wgOpenSearchTemplate, $wgServer;
 476+ global $wgOpenSearchTemplate, $wgCanonicalServer;
477477 if ( $wgOpenSearchTemplate ) {
478478 return $wgOpenSearchTemplate;
479479 } else {
@@ -480,7 +480,7 @@
481481 if ( !$ns ) {
482482 $ns = "0";
483483 }
484 - return $wgServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns;
 484+ return $wgCanonicalServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns;
485485 }
486486 }
487487
Index: branches/REL1_18/phase3/includes/GlobalFunctions.php
@@ -432,6 +432,7 @@
433433 * PROTO_HTTPS: Output a URL starting with https://
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
 436+ * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer
436437 *
437438 * @todo this won't work with current-path-relative URLs
438439 * like "subdir/foo.html", etc.
@@ -441,21 +442,34 @@
442443 * @return string Fully-qualified URL
443444 */
444445 function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
445 - global $wgServer;
 446+ global $wgServer, $wgCanonicalServer;
 447+ $serverUrl = $defaultProto === PROTO_CANONICAL ? $wgCanonicalServer : $wgServer;
 448+
446449 if ( $defaultProto === PROTO_CURRENT ) {
447450 $defaultProto = WebRequest::detectProtocol() . '://';
448451 }
449452
450 - // Analyze $wgServer to obtain its protocol
451 - $bits = wfParseUrl( $wgServer );
 453+ // Analyze $serverUrl to obtain its protocol
 454+ $bits = wfParseUrl( $serverUrl );
452455 $serverHasProto = $bits && $bits['scheme'] != '';
 456+
 457+ if ( $defaultProto === PROTO_CANONICAL ) {
 458+ if ( $serverHasProto ) {
 459+ $defaultProto = $bits['scheme'] . '://';
 460+ } else {
 461+ // $wgCanonicalServer doesn't have a protocol. This really isn't supposed to happen
 462+ // Fall back to HTTP in this ridiculous case
 463+ $defaultProto = PROTO_HTTP;
 464+ }
 465+ }
 466+
453467 $defaultProtoWithoutSlashes = substr( $defaultProto, 0, -2 );
454468
455469 if( substr( $url, 0, 2 ) == '//' ) {
456470 return $defaultProtoWithoutSlashes . $url;
457471 } elseif( substr( $url, 0, 1 ) == '/' ) {
458 - // If $wgServer is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone
459 - return ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $wgServer . $url;
 472+ // If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone
 473+ return ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $serverUrl . $url;
460474 } else {
461475 return $url;
462476 }
Property changes on: branches/REL1_18/phase3/includes/GlobalFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
463477 Merged /trunk/phase3/includes/GlobalFunctions.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894
Index: branches/REL1_18/phase3/includes/Feed.php
@@ -239,12 +239,15 @@
240240 * but can also be called separately.
241241 */
242242 public function httpHeaders() {
243 - global $wgOut;
 243+ global $wgOut, $wgVaryOnXFPForAPI;
244244
245245 # We take over from $wgOut, excepting its cache header info
246246 $wgOut->disable();
247247 $mimetype = $this->contentType();
248248 header( "Content-type: $mimetype; charset=UTF-8" );
 249+ if ( $wgVaryOnXFPForAPI ) {
 250+ $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
 251+ }
249252 $wgOut->sendCacheControl();
250253
251254 }
@@ -273,7 +276,7 @@
274277 $this->httpHeaders();
275278 echo '<?xml version="1.0"?>' . "\n";
276279 echo '<?xml-stylesheet type="text/css" href="' .
277 - htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) .
 280+ htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion", PROTO_CURRENT ) ) .
278281 '"?' . ">\n";
279282 }
280283 }
Index: branches/REL1_18/phase3/includes/UserMailer.php
@@ -509,7 +509,7 @@
510510 $keys = array();
511511
512512 if ( $this->oldid ) {
513 - $difflink = wfExpandUrl( $this->title->getFullUrl( 'diff=0&oldid=' . $this->oldid ), PROTO_HTTP );
 513+ $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid );
514514 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink );
515515 $keys['$OLDID'] = $this->oldid;
516516 $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' );
@@ -526,17 +526,17 @@
527527 * revision.
528528 */
529529 $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff',
530 - wfExpandUrl( $this->title->getFullURL( "oldid={$this->oldid}&diff=next" ), PROTO_HTTP ) );
 530+ $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) );
531531 }
532532
533533 $body = strtr( $body, $keys );
534534 $pagetitle = $this->title->getPrefixedText();
535535 $keys['$PAGETITLE'] = $pagetitle;
536 - $keys['$PAGETITLE_URL'] = wfExpandUrl( $this->title->getFullUrl(), PROTO_HTTP );
 536+ $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl();
537537
538538 $keys['$PAGEMINOREDIT'] = $medit;
539539 $keys['$PAGESUMMARY'] = $summary;
540 - $keys['$UNWATCHURL'] = wfExpandUrl( $this->title->getFullUrl( 'action=unwatch' ), PROTO_HTTP );
 540+ $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' );
541541
542542 $subject = strtr( $subject, $keys );
543543
@@ -571,10 +571,10 @@
572572 $subject = str_replace( '$PAGEEDITOR', $name, $subject );
573573 $keys['$PAGEEDITOR'] = $name;
574574 $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name );
575 - $keys['$PAGEEDITOR_EMAIL'] = wfExpandUrl( $emailPage->getFullUrl(), PROTO_HTTP );
 575+ $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl();
576576 }
577577 $userPage = $editor->getUserPage();
578 - $keys['$PAGEEDITOR_WIKI'] = wfExpandUrl( $userPage->getFullUrl(), PROTO_HTTP );
 578+ $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl();
579579 $body = strtr( $body, $keys );
580580 $body = wordwrap( $body, 72 );
581581
Index: branches/REL1_18/phase3/includes/filerepo/File.php
@@ -215,8 +215,12 @@
216216 * @return String
217217 */
218218 public function getFullUrl() {
219 - return wfExpandUrl( $this->getUrl() );
 219+ return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE );
220220 }
 221+
 222+ public function getCanonicalUrl() {
 223+ return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL );
 224+ }
221225
222226 /**
223227 * @return string
Property changes on: branches/REL1_18/phase3/includes/filerepo/File.php
___________________________________________________________________
Modified: svn:mergeinfo
224228 Merged /trunk/phase3/includes/filerepo/File.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894
Index: branches/REL1_18/phase3/includes/Export.php
@@ -411,7 +411,7 @@
412412 }
413413
414414 function homelink() {
415 - return Xml::element( 'base', array(), Title::newMainPage()->getFullUrl() );
 415+ return Xml::element( 'base', array(), Title::newMainPage()->getCanonicalUrl() );
416416 }
417417
418418 function caseSetting() {
@@ -644,7 +644,7 @@
645645 " " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" .
646646 " " . Xml::element( 'filename', null, $file->getName() ) . "\n" .
647647 $archiveName .
648 - " " . Xml::element( 'src', null, $file->getFullUrl() ) . "\n" .
 648+ " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" .
649649 " " . Xml::element( 'size', null, $file->getSize() ) . "\n" .
650650 " " . Xml::element( 'sha1base36', null, $file->getSha1() ) . "\n" .
651651 " " . Xml::element( 'rel', null, $file->getRel() ) . "\n" .
Index: branches/REL1_18/phase3/includes/OutputPage.php
@@ -1847,7 +1847,7 @@
18481848
18491849 if ( $this->mRedirect != '' ) {
18501850 # Standards require redirect URLs to be absolute
1851 - $this->mRedirect = wfExpandUrl( $this->mRedirect );
 1851+ $this->mRedirect = wfExpandUrl( $this->mRedirect, PROTO_CURRENT );
18521852 if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) {
18531853 if( !$wgDebugRedirects ) {
18541854 $message = HttpStatus::getMessage( $this->mRedirectCode );
@@ -2829,8 +2829,8 @@
28302830 } else {
28312831 $tags[] = Html::element( 'link', array(
28322832 'rel' => 'canonical',
2833 - 'href' => wfExpandUrl( $this->getTitle()->getFullURL(), PROTO_HTTP ) )
2834 - );
 2833+ 'href' => $this->getTitle()->getCanonicalUrl()
 2834+ ) );
28352835 }
28362836 }
28372837
Property changes on: branches/REL1_18/phase3/includes/OutputPage.php
___________________________________________________________________
Modified: svn:mergeinfo
28382838 Merged /trunk/phase3/includes/OutputPage.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894
Index: branches/REL1_18/phase3/includes/actions/RevertAction.php
@@ -96,7 +96,9 @@
9797 'raw' => true,
9898 'default' => wfMsgExt( 'filerevert-intro', 'parse', $this->getTitle()->getText(),
9999 $this->getLang()->date( $timestamp, true ), $this->getLang()->time( $timestamp, true ),
100 - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) )
 100+ wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ),
 101+ PROTO_CURRENT
 102+ ) )
101103 ),
102104 'comment' => array(
103105 'type' => 'text',
@@ -119,7 +121,9 @@
120122 $this->getOutput()->addHTML( wfMsgExt( 'filerevert-success', 'parse', $this->getTitle()->getText(),
121123 $this->getLang()->date( $timestamp, true ),
122124 $this->getLang()->time( $timestamp, true ),
123 - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) ) );
 125+ wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ),
 126+ PROTO_CURRENT
 127+ ) ) );
124128 $this->getOutput()->returnToMain( false, $this->getTitle() );
125129 }
126130
Index: branches/REL1_18/phase3/includes/api/ApiQuerySiteinfo.php
@@ -117,7 +117,7 @@
118118 $data = array();
119119 $mainPage = Title::newMainPage();
120120 $data['mainpage'] = $mainPage->getPrefixedText();
121 - $data['base'] = wfExpandUrl( $mainPage->getFullUrl() );
 121+ $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT );
122122 $data['sitename'] = $GLOBALS['wgSitename'];
123123 $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
124124 $data['phpversion'] = phpversion();
@@ -284,9 +284,13 @@
285285 if ( isset( $langNames[$row->iw_prefix] ) ) {
286286 $val['language'] = $langNames[$row->iw_prefix];
287287 }
288 - $val['url'] = wfExpandUrl( $row->iw_url );
289 - $val['wikiid'] = $row->iw_wikiid;
290 - $val['api'] = $row->iw_api;
 288+ $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
 289+ if( isset( $row['iw_wikiid'] ) ) {
 290+ $val['wikiid'] = $row['iw_wikiid'];
 291+ }
 292+ if( isset( $row['iw_api'] ) ) {
 293+ $val['api'] = $row['iw_api'];
 294+ }
291295
292296 $data[] = $val;
293297 }
@@ -448,7 +452,7 @@
449453 protected function appendRightsInfo( $property ) {
450454 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
451455 $title = Title::newFromText( $wgRightsPage );
452 - $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl;
 456+ $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
453457 $text = $wgRightsText;
454458 if ( !$text && $title ) {
455459 $text = $title->getPrefixedText();
Index: branches/REL1_18/phase3/includes/api/ApiParse.php
@@ -353,7 +353,7 @@
354354
355355 $entry['lang'] = $bits[0];
356356 if ( $title ) {
357 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 357+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
358358 }
359359 $this->getResult()->setContent( $entry, $bits[1] );
360360 $result[] = $entry;
@@ -435,7 +435,7 @@
436436
437437 $title = Title::newFromText( "{$prefix}:{$title}" );
438438 if ( $title ) {
439 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 439+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
440440 }
441441
442442 $this->getResult()->setContent( $entry, $title->getFullText() );
Index: branches/REL1_18/phase3/includes/api/ApiQuery.php
@@ -374,7 +374,7 @@
375375 );
376376 if ( $this->iwUrl ) {
377377 $title = Title::newFromText( $rawTitleStr );
378 - $item['url'] = wfExpandUrl( $title->getFullURL() );
 378+ $item['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
379379 }
380380 $intrwValues[] = $item;
381381 }
Index: branches/REL1_18/phase3/includes/api/ApiQueryIWLinks.php
@@ -112,7 +112,7 @@
113113 if ( !is_null( $params['url'] ) ) {
114114 $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" );
115115 if ( $title ) {
116 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 116+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
117117 }
118118 }
119119
Index: branches/REL1_18/phase3/includes/api/ApiQueryLangLinks.php
@@ -106,7 +106,7 @@
107107 if ( $params['url'] ) {
108108 $title = Title::newFromText( "{$row->ll_lang}:{$row->ll_title}" );
109109 if ( $title ) {
110 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 110+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
111111 }
112112 }
113113 ApiResult::setContent( $entry, $row->ll_title );
Index: branches/REL1_18/phase3/includes/api/ApiQueryImageInfo.php
@@ -348,7 +348,7 @@
349349 if ( !is_null( $thumbParams ) ) {
350350 $mto = $file->transform( $thumbParams );
351351 if ( $mto && !$mto->isError() ) {
352 - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() );
 352+ $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
353353
354354 // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted
355355 // thumbnail sizes for the thumbnail actual size
@@ -370,8 +370,8 @@
371371 $vals['thumberror'] = $mto->toText();
372372 }
373373 }
374 - $vals['url'] = wfExpandUrl( $file->getFullURL() );
375 - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() );
 374+ $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT );
 375+ $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
376376 }
377377
378378 if ( $sha1 ) {
Property changes on: branches/REL1_18/phase3/includes/api/ApiQueryImageInfo.php
___________________________________________________________________
Modified: svn:mergeinfo
379379 Merged /trunk/phase3/includes/api/ApiQueryImageInfo.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894
Index: branches/REL1_18/phase3/includes/api/ApiRsd.php
@@ -48,7 +48,7 @@
4949 $service = array( 'apis' => $this->formatRsdApiList() );
5050 ApiResult::setContent( $service, 'MediaWiki', 'engineName' );
5151 ApiResult::setContent( $service, 'http://www.mediawiki.org/', 'engineLink' );
52 - ApiResult::setContent( $service, wfExpandUrl( Title::newMainPage()->getFullURL() ), 'homePageLink' );
 52+ ApiResult::setContent( $service, Title::newMainPage()->getCanonicalUrl(), 'homePageLink' );
5353
5454 $result->setIndexedTagName( $service['apis'], 'api' );
5555
@@ -98,7 +98,7 @@
9999 $apis = array(
100100 'MediaWiki' => array(
101101 // The API link is required for all RSD API entries.
102 - 'apiLink' => wfExpandUrl( wfScript( 'api' ) ),
 102+ 'apiLink' => wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ),
103103
104104 // Docs link is optional, but recommended.
105105 'docs' => 'http://www.mediawiki.org/wiki/API',
Index: branches/REL1_18/phase3/includes/api/ApiQueryInfo.php
@@ -380,8 +380,8 @@
381381 }
382382
383383 if ( $this->fld_url ) {
384 - $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL() );
385 - $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ) );
 384+ $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
 385+ $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT );
386386 }
387387 if ( $this->fld_readable && $title->userCanRead() ) {
388388 $pageInfo['readable'] = '';
Index: branches/REL1_18/phase3/includes/Title.php
@@ -1013,6 +1013,10 @@
10141014 * Get the URL form for an internal link.
10151015 * - Used in various Squid-related code, in case we have a different
10161016 * internal hostname for the server from the exposed one.
 1017+ *
 1018+ * This uses $wgInternalServer to qualify the path, or $wgServer
 1019+ * if $wgInternalServer is not set. If the server variable used is
 1020+ * protocol-relative, the URL will be expanded to http://
10171021 *
10181022 * @param $query String an optional query string
10191023 * @param $variant String language variant of url (for sr, zh..)
@@ -1021,7 +1025,7 @@
10221026 public function getInternalURL( $query = '', $variant = false ) {
10231027 global $wgInternalServer, $wgServer;
10241028 $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer;
1025 - $url = $server . $this->getLocalURL( $query, $variant );
 1029+ $url = wfExpandUrl( $server . $this->getLocalURL( $query, $variant ), PROTO_HTTP );
10261030 wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
10271031 return $url;
10281032 }
Property changes on: branches/REL1_18/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
10291033 Merged /trunk/phase3/includes/Title.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894
Index: branches/REL1_18/phase3/includes/FileDeleteForm.php
@@ -256,7 +256,7 @@
257257 wfEscapeWikiText( $this->title->getText() ),
258258 $wgLang->date( $this->getTimestamp(), true ),
259259 $wgLang->time( $this->getTimestamp(), true ),
260 - wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) );
 260+ wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) );
261261 } else {
262262 return wfMsgExt(
263263 $message,
Index: branches/REL1_18/phase3/includes/DefaultSettings.php
@@ -1741,9 +1741,9 @@
17421742 $wgUseXVO = false;
17431743
17441744 /** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API
1745 - * requests. Use this if you have an SSL termination setup and want to split
1746 - * the cache between HTTP and HTTPS for API requests. This does not affect
1747 - * 'regular' requests.
 1745+ * requests and RSS/Atom feeds. Use this if you have an SSL termination setup
 1746+ * and need to split the cache between HTTP and HTTPS for API and feed requests
 1747+ * in order to prevent cache pollution. This does not affect 'normal' requests.
17481748 */
17491749 $wgVaryOnXFPForAPI = false;
17501750
Index: branches/REL1_18/phase3/includes/specials/SpecialSearch.php
@@ -28,7 +28,14 @@
2929 * @ingroup SpecialPage
3030 */
3131 class SpecialSearch extends SpecialPage {
32 - /// Current search profile
 32+ /**
 33+ * Current search profile. Search profile is just a name that identifies
 34+ * the active search tab on the search page (content, help, discussions...)
 35+ * For users tt replaces the set of enabled namespaces from the query
 36+ * string when applicable. Extensions can add new profiles with hooks
 37+ * with custom search options just for that profile.
 38+ * null|string
 39+ */
3340 protected $profile;
3441
3542 /// Search engine
@@ -743,13 +750,13 @@
744751 $out = "";
745752 // display project name
746753 if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) {
747 - if( key_exists($t->getInterwiki(),$customCaptions) )
 754+ if( array_key_exists($t->getInterwiki(),$customCaptions) ) {
748755 // captions from 'search-interwiki-custom'
749756 $caption = $customCaptions[$t->getInterwiki()];
750757 else{
751758 // default is to show the hostname of the other wiki which might suck
752759 // if there are many wikis on one hostname
753 - $parsed = parse_url($t->getFullURL());
 760+ $parsed = wfParseUrl( $t->getFullURL() );
754761 $caption = wfMsg('search-interwiki-default', $parsed['host']);
755762 }
756763 // "more results" link (special page stuff could be localized, but we might not know target lang)
Index: branches/REL1_18/phase3/opensearch_desc.php
@@ -51,7 +51,7 @@
5252 'height' => 16,
5353 'width' => 16,
5454 'type' => 'image/x-icon' ),
55 - wfExpandUrl( $wgFavicon ) );
 55+ wfExpandUrl( $wgFavicon , PROTO_CURRENT ) );
5656
5757 $urls = array();
5858
@@ -62,7 +62,7 @@
6363 $urls[] = array(
6464 'type' => 'text/html',
6565 'method' => 'get',
66 - 'template' => $searchPage->getFullURL( 'search={searchTerms}' ) );
 66+ 'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) );
6767
6868 if( $wgEnableAPI ) {
6969 // JSON interface for search suggestions.
@@ -86,6 +86,6 @@
8787 // sends you to the domain root if you hit "enter" with an empty
8888 // search box.
8989 print Xml::element( 'moz:SearchForm', null,
90 - $searchPage->getFullUrl() );
 90+ $searchPage->getCanonicalURL() );
9191
9292 print '</OpenSearchDescription>';

Follow-up revisions

RevisionCommit summaryAuthorDate
r96478Followup r96475: merge the rest of r95000 toocatrope19:45, 7 September 2011
r96506Fix missing }reedy21:40, 7 September 2011
r104573The URL wasn't loading when the database is used (interwiki cache works). "PH...robin16:48, 29 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94737Amend the documention of search profile, fu r86714nikerabbit09:50, 17 August 2011
r94990Followup r94754: move protocol expansion from getIRCLine() to inside getInter...catrope08:56, 19 August 2011
r95000Use canonical URLs (introduced in r94995) in the OpenSearch discovery thingycatrope14:39, 19 August 2011
r95001Make $wgVaryOnXFPForAPI apply to RSS/Atom feeds too, because they too use PRO...catrope14:41, 19 August 2011
r95002Use canonical URLs (introduced in r94995) for all URLs in e-mailscatrope14:46, 19 August 2011
r95006Add a PROTO_CANONICAL mode to wfExpandUrl(), which uses $wgCanonicalServercatrope15:25, 19 August 2011
r95007* Introduce File::getCanonicalUrl()...catrope15:27, 19 August 2011
r95010Make the PROTO_ parameter to wfExpandUrl() explicit in all calls. There are n...catrope15:46, 19 August 2011
r95011Use wfParseUrl() instead of parse_url() in interwiki search code: the latter ...catrope15:56, 19 August 2011
r95894Followup r95002: unbreak getTokenUrl() by using a simpler hack that doesn't i...catrope18:08, 31 August 2011

Status & tagging log