r95010 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95009‎ | r95010 | r95011 >
Date:15:46, 19 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Make the PROTO_ parameter to wfExpandUrl() explicit in all calls. There are now no calls to wfExpandUrl() in core that rely on PROTO_CURRENT being the default. Also switch to using getCanonicalUrl() for.... rel="canonical" :D (I picked the right name, I KNEW IT)
Modified paths:
  • /trunk/phase3/includes/FileDeleteForm.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/actions/RevertAction.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryIWLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiRsd.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -1812,7 +1812,7 @@
18131813
18141814 if ( $this->mRedirect != '' ) {
18151815 # Standards require redirect URLs to be absolute
1816 - $this->mRedirect = wfExpandUrl( $this->mRedirect );
 1816+ $this->mRedirect = wfExpandUrl( $this->mRedirect, PROTO_CURRENT );
18171817 if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) {
18181818 if( !$wgDebugRedirects ) {
18191819 $message = HttpStatus::getMessage( $this->mRedirectCode );
@@ -2822,8 +2822,8 @@
28232823 } else {
28242824 $tags[] = Html::element( 'link', array(
28252825 'rel' => 'canonical',
2826 - 'href' => wfExpandUrl( $this->getTitle()->getFullURL(), PROTO_HTTP ) )
2827 - );
 2826+ 'href' => $this->getTitle()->getCanonicalUrl()
 2827+ ) );
28282828 }
28292829 }
28302830
Index: trunk/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: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -118,7 +118,7 @@
119119 $data = array();
120120 $mainPage = Title::newMainPage();
121121 $data['mainpage'] = $mainPage->getPrefixedText();
122 - $data['base'] = wfExpandUrl( $mainPage->getFullUrl() );
 122+ $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT );
123123 $data['sitename'] = $GLOBALS['wgSitename'];
124124 $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
125125 $data['phpversion'] = phpversion();
@@ -297,7 +297,7 @@
298298 if ( isset( $langNames[$prefix] ) ) {
299299 $val['language'] = $langNames[$prefix];
300300 }
301 - $val['url'] = wfExpandUrl( $row['iw_url'] );
 301+ $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
302302 if( isset( $row['iw_wikiid'] ) ) {
303303 $val['wikiid'] = $row['iw_wikiid'];
304304 }
@@ -465,7 +465,7 @@
466466 protected function appendRightsInfo( $property ) {
467467 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
468468 $title = Title::newFromText( $wgRightsPage );
469 - $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl;
 469+ $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
470470 $text = $wgRightsText;
471471 if ( !$text && $title ) {
472472 $text = $title->getPrefixedText();
Index: trunk/phase3/includes/api/ApiParse.php
@@ -361,7 +361,7 @@
362362
363363 $entry['lang'] = $bits[0];
364364 if ( $title ) {
365 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 365+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
366366 }
367367 $this->getResult()->setContent( $entry, $bits[1] );
368368 $result[] = $entry;
@@ -443,7 +443,7 @@
444444
445445 $title = Title::newFromText( "{$prefix}:{$title}" );
446446 if ( $title ) {
447 - $entry['url'] = wfExpandUrl( $title->getFullURL() );
 447+ $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
448448 }
449449
450450 $this->getResult()->setContent( $entry, $title->getFullText() );
Index: trunk/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: trunk/phase3/includes/api/ApiQueryIWLinks.php
@@ -112,7 +112,7 @@
113113 if ( $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: trunk/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: trunk/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 ) {
Index: trunk/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: trunk/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: trunk/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,

Follow-up revisions

RevisionCommit summaryAuthorDate
r955051.17wmf1: Merge a truckload of HTTPS / prot rel URL fixes: r93847, r94990, r9...catrope19:32, 25 August 2011
r964751.18: MFT r94737, r94990, r95000, r95001, r95002, r95006, r95007, r95010, r95...catrope19:37, 7 September 2011

Status & tagging log