}
}
- $fileMatchesSearch = function( File $file, array $search ) {
+ $fileMatchesSearch = function ( File $file, array $search ) {
// Note: file name comparison done elsewhere (to handle redirects)
+ $user = ( !empty( $search['private'] ) && $search['private'] instanceof User )
+ ? $search['private']
+ : null;
+
return (
$file->exists() &&
(
( !empty( $search['time'] ) && $search['time'] === $file->getTimestamp() )
) &&
( !empty( $search['private'] ) || !$file->isDeleted( File::DELETED_FILE ) ) &&
- $file->userCan( File::DELETED_FILE )
+ $file->userCan( File::DELETED_FILE, $user )
);
};
$repo = $this;
- $applyMatchingFiles = function( ResultWrapper $res, &$searchSet, &$finalFiles )
+ $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
use ( $repo, $fileMatchesSearch, $flags )
{
global $wgContLang;
$dbKeysLook[] = $wgContLang->lcfirst( $file->getName() );
}
foreach ( $dbKeysLook as $dbKey ) {
- if ( isset( $searchSet[$dbKey])
+ if ( isset( $searchSet[$dbKey] )
&& $fileMatchesSearch( $file, $searchSet[$dbKey] )
) {
$finalFiles[$dbKey] = ( $flags & FileRepo::NAME_AND_TIME_ONLY )
foreach ( array_keys( $searchSet ) as $dbKey ) {
$imgNames[] = $this->getNameFromTitle( File::normalizeTitle( $dbKey ) );
}
+
if ( count( $imgNames ) ) {
$res = $dbr->select( 'image',
LocalFile::selectFields(), array( 'img_name' => $imgNames ), __METHOD__ );
// Query old image table
$oiConds = array(); // WHERE clause array for each file
foreach ( $searchSet as $dbKey => $search ) {
- if ( isset( $search['params']['time'] ) ) {
+ if ( isset( $search['time'] ) ) {
$oiConds[] = $dbr->makeList(
array(
'oi_name' => $this->getNameFromTitle( File::normalizeTitle( $dbKey ) ),
- 'oi_timestamp' => $dbr->timestamp( $search['params']['time'] )
+ 'oi_timestamp' => $dbr->timestamp( $search['time'] )
),
LIST_AND
);
}
}
+
if ( count( $oiConds ) ) {
$res = $dbr->select( 'oldimage',
OldLocalFile::selectFields(), $dbr->makeList( $oiConds, LIST_OR ), __METHOD__ );
if ( !empty( $search['ignoreRedirect'] ) ) {
continue;
}
+
$title = File::normalizeTitle( $dbKey );
$redir = $this->checkRedirect( $title ); // hopefully hits memcached
+
if ( $redir && $redir->getNamespace() == NS_FILE ) {
$file = $this->newFile( $redir );
if ( $file && $fileMatchesSearch( $file, $search ) ) {
$file->redirectedFrom( $title->getDBkey() );
if ( $flags & FileRepo::NAME_AND_TIME_ONLY ) {
$finalFiles[$dbKey] = array(
- 'title' => $file->getTitle()->getDBkey(),
+ 'title' => $file->getTitle()->getDBkey(),
'timestamp' => $file->getTimestamp()
);
} else {
$wgMemc->set( $memcKey, ' PURGED', 12 );
}
}
+
+ /**
+ * Return information about the repository.
+ *
+ * @return array
+ * @since 1.22
+ */
+ function getInfo() {
+ global $wgFavicon;
+
+ return array_merge( parent::getInfo(), array(
+ 'favicon' => wfExpandUrl( $wgFavicon ),
+ ) );
+ }
}