(bug 22540) ForeignApiRepos no longer try to store thumbnails that don't exist. Patch...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 17 Feb 2010 00:52:04 +0000 (00:52 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 17 Feb 2010 00:52:04 +0000 (00:52 +0000)
RELEASE-NOTES
includes/filerepo/ForeignAPIRepo.php

index 3e11626..f4e170b 100644 (file)
@@ -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 ==
 
index da920e0..2e50383 100644 (file)
@@ -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" );