From: Sam Reed Date: Thu, 6 Jan 2011 15:47:57 +0000 (+0000) Subject: Fixup my FIXME on r79708 X-Git-Tag: 1.31.0-rc.0~32764 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=a5c538db03e7974ca6881e46022bede451675ee5;p=lhc%2Fweb%2Fwiklou.git Fixup my FIXME on r79708 Check inner array set, before doing count Also add method documentation --- diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 055d3784a6..56fed75e41 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -21,7 +21,13 @@ class ForeignAPIFile extends File { $this->mInfo = $info; $this->mExists = $exists; } - + + /** + * @static + * @param $title Title + * @param $repo ForeignApiRepo + * @return ForeignAPIFile|null + */ static function newFromTitle( $title, $repo ) { $data = $repo->fetchImageQuery( array( 'titles' => 'File:' . $title->getDBKey(), @@ -31,7 +37,9 @@ class ForeignAPIFile extends File { $info = $repo->getImageInfo( $data ); if( $info ) { - $lastRedirect = count( $data['query']['redirects'] ) - 1; + $lastRedirect = isset( $data['query']['redirects'] ) + ? count( $data['query']['redirects'] ) - 1 + : -1; if( $lastRedirect >= 0 ) { $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to']); $img = new ForeignAPIFile( $newtitle, $repo, $info, true );