From 3513a1332f29bcc5c2a39dc76fe992f75a1e9461 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 17 Feb 2010 00:52:04 +0000 Subject: [PATCH] (bug 22540) ForeignApiRepos no longer try to store thumbnails that don't exist. Patch by Derk-Jan Hartman --- RELEASE-NOTES | 1 + includes/filerepo/ForeignAPIRepo.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3e116265f4..f4e170b204 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -762,6 +762,7 @@ comment from another wiki. template parameter * Truncate summary of page moves in revision comment field to avoid broken multibyte characters +* (bug 22540) ForeignApiRepos no longer try to store thumbnails that don't exist == API changes in 1.16 == diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index da920e0836..2e50383622 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -175,7 +175,7 @@ class ForeignAPIRepo extends FileRepo { 'iiurlwidth' => $width, 'iiurlheight' => $height, 'prop' => 'imageinfo' ) ); - if( $info ) { + if( $info && $info['thumburl'] ) { wfDebug( __METHOD__ . " got remote thumb " . $info['thumburl'] . "\n" ); return $info['thumburl']; } else { @@ -197,7 +197,15 @@ class ForeignAPIRepo extends FileRepo { } else { $foreignUrl = $this->getThumbUrl( $name, $width, $height ); - + if( !$foreignUrl ) { + wfDebug( __METHOD__ . " Could not find thumburl\n" ); + return false; + } + $thumb = Http::get( $foreignUrl ); + if( !$thumb ) { + wfDebug( __METHOD__ . " Could not download thumb\n" ); + return false; + } // We need the same filename as the remote one :) $fileName = rawurldecode( pathinfo( $foreignUrl, PATHINFO_BASENAME ) ); $path = 'thumb/' . $this->getHashPath( $name ) . $name . "/"; @@ -205,7 +213,6 @@ class ForeignAPIRepo extends FileRepo { wfMkdirParents($wgUploadDirectory . '/' . $path); } $localUrl = $wgServer . $wgUploadPath . '/' . $path . $fileName; - $thumb = Http::get( $foreignUrl ); # FIXME: Delete old thumbs that aren't being used. Maintenance script? if( !file_put_contents($wgUploadDirectory . '/' . $path . $fileName, $thumb ) ) { wfDebug( __METHOD__ . " could not write to thumb path\n" ); -- 2.20.1