r93802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93801‎ | r93802 | r93803 >
Date:07:05, 3 August 2011
Author:catrope
Status:reverted (Comments)
Tags:
Comment:
Followup r92044: force HTTP on URLs output by the API, now that wfExpandUrl() has a flag for this
Modified paths:
  • /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)

Diff [purge]

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_HTTP );
379379 }
380380 $intrwValues[] = $item;
381381 }
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_HTTP );
 385+ $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_HTTP );
386386 }
387387 if ( $this->fld_readable && $title->userCanRead() ) {
388388 $pageInfo['readable'] = '';
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_HTTP );
117117 }
118118 }
119119
Index: trunk/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_HTTP );
122122 $data['sitename'] = $GLOBALS['wgSitename'];
123123 $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
124124 $data['phpversion'] = phpversion();
@@ -288,7 +288,7 @@
289289 if ( isset( $langNames[$prefix] ) ) {
290290 $val['language'] = $langNames[$prefix];
291291 }
292 - $val['url'] = wfExpandUrl( $row['iw_url'] );
 292+ $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_HTTP );
293293 if( isset( $row['iw_wikiid'] ) ) {
294294 $val['wikiid'] = $row['iw_wikiid'];
295295 }
@@ -456,7 +456,7 @@
457457 protected function appendRightsInfo( $property ) {
458458 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
459459 $title = Title::newFromText( $wgRightsPage );
460 - $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl;
 460+ $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_HTTP ) : $wgRightsUrl;
461461 $text = $wgRightsText;
462462 if ( !$text && $title ) {
463463 $text = $title->getPrefixedText();
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_HTTP );
111111 }
112112 }
113113 ApiResult::setContent( $entry, $row->ll_title );
Index: trunk/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_HTTP );
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_HTTP );
440440 }
441441
442442 $this->getResult()->setContent( $entry, $title->getFullText() );
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_HTTP );
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

Follow-up revisions

RevisionCommit summaryAuthorDate
r93806Revert r93802 per CR. Will avoid cache pollution by splitting the cache insteadcatrope07:54, 3 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r92044Per wikitech-l, run a bunch of URLs in the API output through wfExpandUrl(), ...catrope01:27, 13 July 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   07:21, 3 August 2011

Does this mean an API client has no way of knowing that these URLs could be accessed over SSL as well?

#Comment by Catrope (talk | contribs)   07:48, 3 August 2011

After talking to Brion in person, we decided it'd be best to use PROT_CURRENT. Because that would introduce cache pollution though, we'll have to split the API cache into HTTP and HTTPS.

#Comment by Catrope (talk | contribs)   07:49, 3 August 2011

After talking to Brion in person, we decided it'd be best to use PROT_CURRENT. Because that would introduce cache pollution though, we'll have to split the API cache into HTTP and HTTPS.

Status & tagging log