Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / filerepo / LocalRepo.php
index 20d51c2..f5b83ae 100644 (file)
@@ -274,14 +274,13 @@ class LocalRepo extends FileRepo {
                        );
                };
 
-               $that = $this;
                $applyMatchingFiles = function ( ResultWrapper $res, &$searchSet, &$finalFiles )
-                       use ( $that, $fileMatchesSearch, $flags )
+                       use ( $fileMatchesSearch, $flags )
                {
                        global $wgContLang;
-                       $info = $that->getInfo();
+                       $info = $this->getInfo();
                        foreach ( $res as $row ) {
-                               $file = $that->newFileFromRow( $row );
+                               $file = $this->newFileFromRow( $row );
                                // There must have been a search for this DB key, but this has to handle the
                                // cases were title capitalization is different on the client and repo wikis.
                                $dbKeysLook = [ strtr( $file->getName(), ' ', '_' ) ];
@@ -311,8 +310,9 @@ class LocalRepo extends FileRepo {
                }
 
                if ( count( $imgNames ) ) {
-                       $res = $dbr->select( 'image',
-                               LocalFile::selectFields(), [ 'img_name' => $imgNames ], __METHOD__ );
+                       $fileQuery = LocalFile::getQueryInfo();
+                       $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'], [ 'img_name' => $imgNames ],
+                               __METHOD__, [], $fileQuery['joins'] );
                        $applyMatchingFiles( $res, $searchSet, $finalFiles );
                }
 
@@ -331,8 +331,10 @@ class LocalRepo extends FileRepo {
                }
 
                if ( count( $oiConds ) ) {
-                       $res = $dbr->select( 'oldimage',
-                               OldLocalFile::selectFields(), $dbr->makeList( $oiConds, LIST_OR ), __METHOD__ );
+                       $fileQuery = OldLocalFile::getQueryInfo();
+                       $res = $dbr->select( $fileQuery['tables'], $fileQuery['fields'],
+                               $dbr->makeList( $oiConds, LIST_OR ),
+                               __METHOD__, [], $fileQuery['joins'] );
                        $applyMatchingFiles( $res, $searchSet, $finalFiles );
                }
 
@@ -373,12 +375,14 @@ class LocalRepo extends FileRepo {
         */
        function findBySha1( $hash ) {
                $dbr = $this->getReplicaDB();
+               $fileQuery = LocalFile::getQueryInfo();
                $res = $dbr->select(
-                       'image',
-                       LocalFile::selectFields(),
+                       $fileQuery['tables'],
+                       $fileQuery['fields'],
                        [ 'img_sha1' => $hash ],
                        __METHOD__,
-                       [ 'ORDER BY' => 'img_name' ]
+                       [ 'ORDER BY' => 'img_name' ],
+                       $fileQuery['joins']
                );
 
                $result = [];
@@ -405,12 +409,14 @@ class LocalRepo extends FileRepo {
                }
 
                $dbr = $this->getReplicaDB();
+               $fileQuery = LocalFile::getQueryInfo();
                $res = $dbr->select(
-                       'image',
-                       LocalFile::selectFields(),
+                       $fileQuery['tables'],
+                       $fileQuery['fields'],
                        [ 'img_sha1' => $hashes ],
                        __METHOD__,
-                       [ 'ORDER BY' => 'img_name' ]
+                       [ 'ORDER BY' => 'img_name' ],
+                       $fileQuery['joins']
                );
 
                $result = [];
@@ -435,12 +441,14 @@ class LocalRepo extends FileRepo {
 
                // Query database
                $dbr = $this->getReplicaDB();
+               $fileQuery = LocalFile::getQueryInfo();
                $res = $dbr->select(
-                       'image',
-                       LocalFile::selectFields(),
+                       $fileQuery['tables'],
+                       $fileQuery['fields'],
                        'img_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ),
                        __METHOD__,
-                       $selectOptions
+                       $selectOptions,
+                       $fileQuery['joins']
                );
 
                // Build file objects