r51673 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51672‎ | r51673 | r51674 >
Date:01:47, 10 June 2009
Author:demon
Status:resolved (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/includes/filerepo/ForeignAPIRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -403,7 +403,7 @@
404404
405405 function fileExists( $file, $flags = 0 ) {
406406 $result = $this->fileExistsBatch( array( $file ), $flags );
407 - return $file;
 407+ return $result[0];
408408 }
409409
410410 /**
Index: trunk/phase3/includes/filerepo/ForeignAPIRepo.php
@@ -21,6 +21,7 @@
2222 var $fileFactory = array( 'ForeignAPIFile', 'newFromTitle' );
2323 var $apiThumbCacheExpiry = 0;
2424 protected $mQueryCache = array();
 25+ protected $mFileExists = array();
2526
2627 function __construct( $info ) {
2728 parent::__construct( $info );
@@ -57,8 +58,32 @@
5859 function deleteBatch( $sourceDestPairs ) {
5960 return false;
6061 }
 62+
 63+
6164 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+ }
6388 }
6489 function getFileProps( $virtualUrl ) {
6590 return false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r80137Fix broken fileExistsBatch() in ForeignAPIRepo since r51673demon00:11, 13 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51592Add fileExistsBatch method to FileRepo and derived classes (per comments on r...vasilievvv15:10, 8 June 2009

Comments

#Comment by Reedy (talk | contribs)   00:06, 13 January 2011

$data seems to be completely undefined here.. (not even some magical extract()...)

It also doesn't return anything.. I'm guessing return $result; was wanted?

Status & tagging log