Index: trunk/phase3/includes/filerepo/ForeignAPIFile.php |
— | — | @@ -30,11 +30,14 @@ |
31 | 31 | |
32 | 32 | $info = $repo->getImageInfo( $data ); |
33 | 33 | |
34 | | - if( $data && $info) { |
35 | | - if( isset( $data['query']['redirects'][0] ) ) { |
36 | | - $newtitle = Title::newFromText( $data['query']['redirects'][0]['to']); |
| 34 | + if( $info ) { |
| 35 | + $lastRedirect = count( $data['query']['redirects'] ) - 1; |
| 36 | + if( $lastRedirect >= 0 ) { |
| 37 | + $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to']); |
37 | 38 | $img = new ForeignAPIFile( $newtitle, $repo, $info, true ); |
38 | | - if( $img ) $img->redirectedFrom( $title->getDBkey() ); |
| 39 | + if( $img ) { |
| 40 | + $img->redirectedFrom( $title->getDBkey() ); |
| 41 | + } |
39 | 42 | } else { |
40 | 43 | $img = new ForeignAPIFile( $title, $repo, $info, true ); |
41 | 44 | } |