From: Chad Horohoe Date: Sun, 14 Dec 2008 07:02:44 +0000 (+0000) Subject: Add some sanity checking. Return nicely if Http::get fails (in general) on fetchImage... X-Git-Tag: 1.31.0-rc.0~43978 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=06bb3af12e0710a5522af814e52249ead66f2ee1;p=lhc%2Fweb%2Fwiklou.git Add some sanity checking. Return nicely if Http::get fails (in general) on fetchImageQuery(), and also if our query returns poorly in findBySha1(), similar to queryImage(). --- diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index 8f9dabfa33..6fc9c46528 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -79,6 +79,9 @@ class ForeignAPIRepo extends FileRepo { $data = $wgMemc->get( $key ); if( !$data ) { $data = Http::get( $url ); + if ( !$data ) { + return null; + } $wgMemc->set( $key, $data, 3600 ); } @@ -104,8 +107,10 @@ class ForeignAPIRepo extends FileRepo { 'aiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime', 'list' => 'allimages', ) ); $ret = array(); - foreach ( $results['query']['allimages'] as $img ) { - $ret[] = new ForeignAPIFile( Title::makeTitle( NS_IMAGE, $img['name'] ), $this, $img ); + if ( isset( $results['query']['allimages'] ) ) { + foreach ( $results['query']['allimages'] as $img ) { + $ret[] = new ForeignAPIFile( Title::makeTitle( NS_IMAGE, $img['name'] ), $this, $img ); + } } return $ret; }