const OVERWRITE_SAME = 4;
const SKIP_LOCKING = 8;
+ const TIME_ONLY = 1;
+
/** @var bool Whether to fetch commons image description pages and display
* them on the local wiki */
public $fetchDescription;
* $repo->findFiles( $findBatch );
*
* No title should appear in $items twice, as the result use titles as keys
- * @return array (Map of file names => File objects) for matches
+ * @param int $flags Supports:
+ * - FileRepo::TIME_ONLY : return a (file name => timestamp) map instead
+ * @return array Map of (file name => File objects) for matches
*/
- public function findFiles( array $items ) {
+ public function findFiles( array $items, $flags = 0 ) {
$result = array();
foreach ( $items as $item ) {
if ( is_array( $item ) ) {
}
$file = $this->findFile( $title, $options );
if ( $file ) {
- $result[$file->getTitle()->getDBkey()] = $file;
+ $result[$file->getTitle()->getDBkey()] =
+ ( $flags & self::TIME_ONLY ) ? $file->getTimestamp() : $file;
}
}
return $id;
}
- public function findFiles( array $items ) {
+ public function findFiles( array $items, $flags = 0 ) {
$finalFiles = array(); // map of (DB key => corresponding File) for matches
$searchSet = array(); // map of (DB key => normalized search params)
$repo = $this;
$applyMatchingFiles = function( ResultWrapper $res, &$searchSet, &$finalFiles )
- use ( $repo, $fileMatchesSearch )
+ use ( $repo, $fileMatchesSearch, $flags )
{
foreach ( $res as $row ) {
- $possFile = $repo->newFileFromRow( $row );
- $dbKey = $possFile->getName();
+ $file = $repo->newFileFromRow( $row );
+ $dbKey = $file->getName();
// There must have been a search for this DB Key
- if ( $fileMatchesSearch( $possFile, $searchSet[$dbKey] ) ) {
- $finalFiles[$dbKey] = $possFile;
+ if ( $fileMatchesSearch( $file, $searchSet[$dbKey] ) ) {
+ $finalFiles[$dbKey] =
+ ( $flags & FileRepo::TIME_ONLY ) ? $file->getTimestamp() : $file;
unset( $searchSet[$dbKey] );
}
}
$title = File::normalizeTitle( $dbKey );
$redir = $this->checkRedirect( $title ); // hopefully hits memcached
if ( $redir && $redir->getNamespace() == NS_FILE ) {
- $possFile = $this->newFile( $redir );
- if ( $possFile && $fileMatchesSearch( $possFile, $search ) ) {
- $possFile->redirectedFrom( $title->getDBkey() );
- $finalFiles[$dbKey] = $possFile;
+ $file = $this->newFile( $redir );
+ if ( $file && $fileMatchesSearch( $file, $search ) ) {
+ $file->redirectedFrom( $title->getDBkey() );
+ $finalFiles[$dbKey] =
+ ( $flags & FileRepo::TIME_ONLY ) ? $file->getTimestamp() : $file;
}
}
}