r62634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62633‎ | r62634 | r62635 >
Date:00:52, 17 February 2010
Author:demon
Status:ok
Tags:
Comment:
(bug 22540) ForeignApiRepos no longer try to store thumbnails that don't exist. Patch by Derk-Jan Hartman
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -175,7 +175,7 @@
176176 'iiurlwidth' => $width,
177177 'iiurlheight' => $height,
178178 'prop' => 'imageinfo' ) );
179 - if( $info ) {
 179+ if( $info && $info['thumburl'] ) {
180180 wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" );
181181 return $info['thumburl'];
182182 } else {
@@ -197,7 +197,15 @@
198198 }
199199 else {
200200 $foreignUrl = $this->getThumbUrl( $name, $width, $height );
201 -
 201+ if( !$foreignUrl ) {
 202+ wfDebug( __METHOD__ . " Could not find thumburl\n" );
 203+ return false;
 204+ }
 205+ $thumb = Http::get( $foreignUrl );
 206+ if( !$thumb ) {
 207+ wfDebug( __METHOD__ . " Could not download thumb\n" );
 208+ return false;
 209+ }
202210 // We need the same filename as the remote one :)
203211 $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) );
204212 $path = 'thumb/' . $this->getHashPath( $name ) . $name . "/";
@@ -205,7 +213,6 @@
206214 wfMkdirParents($wgUploadDirectory . '/' . $path);
207215 }
208216 $localUrl = $wgServer . $wgUploadPath . '/' . $path . $fileName;
209 - $thumb = Http::get( $foreignUrl );
210217 # FIXME: Delete old thumbs that aren't being used. Maintenance script?
211218 if( !file_put_contents($wgUploadDirectory . '/' . $path . $fileName, $thumb ) ) {
212219 wfDebug( __METHOD__ . " could not write to thumb path\n" );
Index: trunk/phase3/RELEASE-NOTES
@@ -762,6 +762,7 @@
763763 template parameter
764764 * Truncate summary of page moves in revision comment field to avoid broken
765765 multibyte characters
 766+* (bug 22540) ForeignApiRepos no longer try to store thumbnails that don't exist
766767
767768 == API changes in 1.16 ==
768769

Status & tagging log