Revision: 51673 Author: demon Date: 2009-06-10 01:47:58 +0000 (Wed, 10 Jun 2009)
Log Message: ----------- Followup to r51592: * Implement fileExistsBatch() in the ForeignAPIRepo. * Tweak fileExists() to return the boolean from the single file we checked, not the file we were given. Modified Paths: -------------- trunk/phase3/includes/filerepo/FileRepo.php trunk/phase3/includes/filerepo/ForeignAPIRepo.php Modified: trunk/phase3/includes/filerepo/FileRepo.php =================================================================== --- trunk/phase3/includes/filerepo/FileRepo.php 2009-06-10 01:08:20 UTC (rev 51672) +++ trunk/phase3/includes/filerepo/FileRepo.php 2009-06-10 01:47:58 UTC (rev 51673) @@ -403,7 +403,7 @@ function fileExists( $file, $flags = 0 ) { $result = $this->fileExistsBatch( array( $file ), $flags ); - return $file; + return $result[0]; } /** Modified: trunk/phase3/includes/filerepo/ForeignAPIRepo.php =================================================================== --- trunk/phase3/includes/filerepo/ForeignAPIRepo.php 2009-06-10 01:08:20 UTC (rev 51672) +++ trunk/phase3/includes/filerepo/ForeignAPIRepo.php 2009-06-10 01:47:58 UTC (rev 51673) @@ -21,6 +21,7 @@ var $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' ); var $apiThumbCacheExpiry = 0; protected $mQueryCache = array(); + protected $mFileExists = array(); function __construct( $info ) { parent::__construct( $info ); @@ -57,8 +58,32 @@ function deleteBatch( $sourceDestPairs ) { return false; } + + function fileExistsBatch( $files, $flags = 0 ) { - return false; + $results = array(); + foreach ( $files as $k => $f ) { + if ( isset( $this->mFileExists[$k] ) ) { + $results[$k] = true; + unset( $files[$k] ); + } elseif( self::isVirtualUrl( $f ) ) { + # TODO! FIXME! We need to be able to handle virtual + # URLs better, at least when we know they refer to the + # same repo. + $results[$k] = false; + unset( $files[$k] ); + } + } + + $results = $this->fetchImageQuery( array( 'titles' => implode( $files, '|' ), + 'prop' => 'imageinfo' ) ); + if( isset( $data['query']['pages'] ) ) { + $i = 0; + foreach( $files as $key => $file ) { + $results[$key] = $this->mFileExists[$key] = !isset( $data['query']['pages'][$i]['missing'] ); + $i++; + } + } } function getFileProps( $virtualUrl ) { return false; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs