Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php |
— | — | @@ -21,7 +21,13 @@ |
22 | 22 | $this->mInfo = $info; |
23 | 23 | $this->mExists = $exists; |
24 | 24 | } |
25 | | - |
| 25 | + |
| 26 | + /** |
| 27 | + * @static |
| 28 | + * @param $title Title |
| 29 | + * @param $repo ForeignApiRepo |
| 30 | + * @return ForeignAPIFile|null |
| 31 | + */ |
26 | 32 | static function newFromTitle( $title, $repo ) { |
27 | 33 | $data = $repo->fetchImageQuery( array( |
28 | 34 | 'titles' => 'File:' . $title->getDBKey(), |
— | — | @@ -31,7 +37,9 @@ |
32 | 38 | $info = $repo->getImageInfo( $data ); |
33 | 39 | |
34 | 40 | if( $info ) { |
35 | | - $lastRedirect = count( $data['query']['redirects'] ) - 1; |
| 41 | + $lastRedirect = isset( $data['query']['redirects'] ) |
| 42 | + ? count( $data['query']['redirects'] ) - 1 |
| 43 | + : -1; |
36 | 44 | if( $lastRedirect >= 0 ) { |
37 | 45 | $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to']); |
38 | 46 | $img = new ForeignAPIFile( $newtitle, $repo, $info, true ); |