Index: trunk/phase3/includes/filerepo/FileRepo.php |
— | — | @@ -403,7 +403,7 @@ |
404 | 404 | |
405 | 405 | function fileExists( $file, $flags = 0 ) { |
406 | 406 | $result = $this->fileExistsBatch( array( $file ), $flags ); |
407 | | - return $file; |
| 407 | + return $result[0]; |
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | var $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ); |
23 | 23 | var $apiThumbCacheExpiry = 0; |
24 | 24 | protected $mQueryCache = array(); |
| 25 | + protected $mFileExists = array(); |
25 | 26 | |
26 | 27 | function __construct( $info ) { |
27 | 28 | parent::__construct( $info ); |
— | — | @@ -57,8 +58,32 @@ |
58 | 59 | function deleteBatch( $sourceDestPairs ) { |
59 | 60 | return false; |
60 | 61 | } |
| 62 | + |
| 63 | + |
61 | 64 | function fileExistsBatch( $files, $flags = 0 ) { |
62 | | - return false; |
| 65 | + $results = array(); |
| 66 | + foreach ( $files as $k => $f ) { |
| 67 | + if ( isset( $this->mFileExists[$k] ) ) { |
| 68 | + $results[$k] = true; |
| 69 | + unset( $files[$k] ); |
| 70 | + } elseif( self::isVirtualUrl( $f ) ) { |
| 71 | + # TODO! FIXME! We need to be able to handle virtual |
| 72 | + # URLs better, at least when we know they refer to the |
| 73 | + # same repo. |
| 74 | + $results[$k] = false; |
| 75 | + unset( $files[$k] ); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + $results = $this->fetchImageQuery( array( 'titles' => implode( $files, '|' ), |
| 80 | + 'prop' => 'imageinfo' ) ); |
| 81 | + if( isset( $data['query']['pages'] ) ) { |
| 82 | + $i = 0; |
| 83 | + foreach( $files as $key => $file ) { |
| 84 | + $results[$key] = $this->mFileExists[$key] = !isset( $data['query']['pages'][$i]['missing'] ); |
| 85 | + $i++; |
| 86 | + } |
| 87 | + } |
63 | 88 | } |
64 | 89 | function getFileProps( $virtualUrl ) { |
65 | 90 | return false; |