/**
* @throws MWException
- * @param array $row
+ * @param stdClass $row
* @return LocalFile
*/
function newFileFromRow( $row ) {
$hashPath = $this->getDeletedHashPath( $key );
$path = "$root/$hashPath$key";
$dbw->begin( __METHOD__ );
- // Check for usage in deleted/hidden files and pre-emptively
+ // Check for usage in deleted/hidden files and preemptively
// lock the key to avoid any future use until we are finished.
$deleted = $this->deletedFileHasKey( $key, 'lock' );
$hidden = $this->hiddenFileHasKey( $key, 'lock' );
* Checks if there is a redirect named as $title
*
* @param Title $title Title of file
- * @return bool
+ * @return bool|Title
*/
function checkRedirect( Title $title ) {
global $wgMemc;
}
}
- $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() &&
(
};
$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__ );
);
}
}
+
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 {
* Get an array or iterator of file objects for files that have a given
* SHA-1 content hash.
*
- * @param string $hash a sha1 hash to look for
- * @return array
+ * @param string $hash A sha1 hash to look for
+ * @return File[]
*/
function findBySha1( $hash ) {
$dbr = $this->getSlaveDB();
*/
function getInfo() {
global $wgFavicon;
+
return array_merge( parent::getInfo(), array(
'favicon' => wfExpandUrl( $wgFavicon ),
) );