r34877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34876‎ | r34877 | r34878 >
Date:18:33, 15 May 2008
Author:btongminh
Status:old
Tags:
Comment:
Force output of a full URL in Special:Filepath and ApiQueryImageInfo in case the wiki images are not configured to full urls.
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/includes/SpecialFilepath.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImageInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryImageInfo.php
@@ -129,12 +129,12 @@
130130 $thumb = $f->getThumbnail($this->urlwidth, $this->urlheight);
131131 if($thumb)
132132 {
133 - $vals['thumburl'] = $thumb->getURL();
 133+ $vals['thumburl'] = Http::makeFullUrl( $thumb->getURL() );
134134 $vals['thumbwidth'] = $thumb->getWidth();
135135 $vals['thumbheight'] = $thumb->getHeight();
136136 }
137137 }
138 - $vals['url'] = $f->getURL();
 138+ $vals['url'] = Http::makeFullUrl( $f->getURL() );
139139 }
140140 if($this->fld_comment)
141141 $vals['comment'] = $f->getDescription();
Index: trunk/phase3/includes/SpecialFilepath.php
@@ -13,7 +13,8 @@
1414 } else {
1515 $file = wfFindFile( $title );
1616 if ( $file && $file->exists() ) {
17 - $wgOut->redirect( $file->getURL() );
 17+ // Force a real 30x so the real url is always exposed
 18+ $wgOut->redirect( Http::makeFullURL( $file->getURL() ) );
1819 } else {
1920 $wgOut->setStatusCode( 404 );
2021 $cform = new FilepathForm( $title );
Index: trunk/phase3/includes/HttpFunctions.php
@@ -117,4 +117,20 @@
118118 }
119119 return false;
120120 }
 121+
 122+ /*
 123+ * Return the full url of something relative to $wgScriptPath or root
 124+ */
 125+ static function makeFullURL( $url ) {
 126+ global $wgServer, $wgScriptPath;
 127+
 128+ // This is a full url
 129+ if ( strpos( $url, '://' ) !== false ) return $url;
 130+
 131+ // This is a relative path
 132+ if ( substr( $url, 0, 1 ) != '/' )
 133+ $url = $wgScriptPath.'/'.$url;
 134+
 135+ return $wgServer.$url;
 136+ }
121137 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r34886Revert r34877 -- duplicates wfExpandUrl()brion19:42, 15 May 2008

Status & tagging log