From d8a27337570dc22d138ddbc3ac9a3dee6880c96e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 19 Aug 2011 15:46:08 +0000 Subject: [PATCH] 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) --- includes/FileDeleteForm.php | 2 +- includes/OutputPage.php | 6 +++--- includes/actions/RevertAction.php | 8 ++++++-- includes/api/ApiParse.php | 4 ++-- includes/api/ApiQuery.php | 2 +- includes/api/ApiQueryIWLinks.php | 2 +- includes/api/ApiQueryImageInfo.php | 6 +++--- includes/api/ApiQueryInfo.php | 4 ++-- includes/api/ApiQueryLangLinks.php | 2 +- includes/api/ApiQuerySiteinfo.php | 6 +++--- includes/api/ApiRsd.php | 4 ++-- 11 files changed, 25 insertions(+), 21 deletions(-) diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 54c19f0f59..515768ff7c 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -256,7 +256,7 @@ class FileDeleteForm { wfEscapeWikiText( $this->title->getText() ), $wgLang->date( $this->getTimestamp(), true ), $wgLang->time( $this->getTimestamp(), true ), - wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) ); + wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) ); } else { return wfMsgExt( $message, diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 33e4bbd007..0a6af95282 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1812,7 +1812,7 @@ class OutputPage extends ContextSource { if ( $this->mRedirect != '' ) { # Standards require redirect URLs to be absolute - $this->mRedirect = wfExpandUrl( $this->mRedirect ); + $this->mRedirect = wfExpandUrl( $this->mRedirect, PROTO_CURRENT ); if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) { if( !$wgDebugRedirects ) { $message = HttpStatus::getMessage( $this->mRedirectCode ); @@ -2822,8 +2822,8 @@ $templates } else { $tags[] = Html::element( 'link', array( 'rel' => 'canonical', - 'href' => wfExpandUrl( $this->getTitle()->getFullURL(), PROTO_HTTP ) ) - ); + 'href' => $this->getTitle()->getCanonicalUrl() + ) ); } } diff --git a/includes/actions/RevertAction.php b/includes/actions/RevertAction.php index 815606d7f4..bcb8cd8ba9 100644 --- a/includes/actions/RevertAction.php +++ b/includes/actions/RevertAction.php @@ -96,7 +96,9 @@ class RevertFileAction extends FormAction { 'raw' => true, 'default' => wfMsgExt( 'filerevert-intro', 'parse', $this->getTitle()->getText(), $this->getLang()->date( $timestamp, true ), $this->getLang()->time( $timestamp, true ), - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) ) + wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), + PROTO_CURRENT + ) ) ), 'comment' => array( 'type' => 'text', @@ -119,7 +121,9 @@ class RevertFileAction extends FormAction { $this->getOutput()->addHTML( wfMsgExt( 'filerevert-success', 'parse', $this->getTitle()->getText(), $this->getLang()->date( $timestamp, true ), $this->getLang()->time( $timestamp, true ), - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) ) ); + wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), + PROTO_CURRENT + ) ) ); $this->getOutput()->returnToMain( false, $this->getTitle() ); } diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 8f95d2ea87..d963f8c94b 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -361,7 +361,7 @@ class ApiParse extends ApiBase { $entry['lang'] = $bits[0]; if ( $title ) { - $entry['url'] = wfExpandUrl( $title->getFullURL() ); + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); } $this->getResult()->setContent( $entry, $bits[1] ); $result[] = $entry; @@ -443,7 +443,7 @@ class ApiParse extends ApiBase { $title = Title::newFromText( "{$prefix}:{$title}" ); if ( $title ) { - $entry['url'] = wfExpandUrl( $title->getFullURL() ); + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); } $this->getResult()->setContent( $entry, $title->getFullText() ); diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 696b5165cb..5279db93db 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -374,7 +374,7 @@ class ApiQuery extends ApiBase { ); if ( $this->iwUrl ) { $title = Title::newFromText( $rawTitleStr ); - $item['url'] = wfExpandUrl( $title->getFullURL() ); + $item['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); } $intrwValues[] = $item; } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 9a18e30073..569f36f3fe 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -112,7 +112,7 @@ class ApiQueryIWLinks extends ApiQueryBase { if ( $params['url'] ) { $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" ); if ( $title ) { - $entry['url'] = wfExpandUrl( $title->getFullURL() ); + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); } } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 1f91156303..03e11b7c3e 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -348,7 +348,7 @@ class ApiQueryImageInfo extends ApiQueryBase { if ( !is_null( $thumbParams ) ) { $mto = $file->transform( $thumbParams ); if ( $mto && !$mto->isError() ) { - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() ); + $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT ); // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted // thumbnail sizes for the thumbnail actual size @@ -370,8 +370,8 @@ class ApiQueryImageInfo extends ApiQueryBase { $vals['thumberror'] = $mto->toText(); } } - $vals['url'] = wfExpandUrl( $file->getFullURL() ); - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); + $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT ); + $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT ); } if ( $sha1 ) { diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 5d2252700f..9170b73261 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -380,8 +380,8 @@ class ApiQueryInfo extends ApiQueryBase { } if ( $this->fld_url ) { - $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL() ); - $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ) ); + $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); + $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT ); } if ( $this->fld_readable && $title->userCanRead() ) { $pageInfo['readable'] = ''; diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 2583790efa..b0880bb5ef 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -106,7 +106,7 @@ class ApiQueryLangLinks extends ApiQueryBase { if ( $params['url'] ) { $title = Title::newFromText( "{$row->ll_lang}:{$row->ll_title}" ); if ( $title ) { - $entry['url'] = wfExpandUrl( $title->getFullURL() ); + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); } } ApiResult::setContent( $entry, $row->ll_title ); diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 3c618244fd..4f22f537bb 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -118,7 +118,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data = array(); $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); - $data['base'] = wfExpandUrl( $mainPage->getFullUrl() ); + $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT ); $data['sitename'] = $GLOBALS['wgSitename']; $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; $data['phpversion'] = phpversion(); @@ -297,7 +297,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( isset( $langNames[$prefix] ) ) { $val['language'] = $langNames[$prefix]; } - $val['url'] = wfExpandUrl( $row['iw_url'] ); + $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT ); if( isset( $row['iw_wikiid'] ) ) { $val['wikiid'] = $row['iw_wikiid']; } @@ -465,7 +465,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendRightsInfo( $property ) { global $wgRightsPage, $wgRightsUrl, $wgRightsText; $title = Title::newFromText( $wgRightsPage ); - $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl; + $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl; $text = $wgRightsText; if ( !$text && $title ) { $text = $title->getPrefixedText(); diff --git a/includes/api/ApiRsd.php b/includes/api/ApiRsd.php index a806c3acf3..3bca7259be 100644 --- a/includes/api/ApiRsd.php +++ b/includes/api/ApiRsd.php @@ -48,7 +48,7 @@ class ApiRsd extends ApiBase { $service = array( 'apis' => $this->formatRsdApiList() ); ApiResult::setContent( $service, 'MediaWiki', 'engineName' ); ApiResult::setContent( $service, 'http://www.mediawiki.org/', 'engineLink' ); - ApiResult::setContent( $service, wfExpandUrl( Title::newMainPage()->getFullURL() ), 'homePageLink' ); + ApiResult::setContent( $service, Title::newMainPage()->getCanonicalUrl(), 'homePageLink' ); $result->setIndexedTagName( $service['apis'], 'api' ); @@ -98,7 +98,7 @@ class ApiRsd extends ApiBase { $apis = array( 'MediaWiki' => array( // The API link is required for all RSD API entries. - 'apiLink' => wfExpandUrl( wfScript( 'api' ) ), + 'apiLink' => wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ), // Docs link is optional, but recommended. 'docs' => 'http://www.mediawiki.org/wiki/API', -- 2.20.1