Merge "Fix param type of search terms in search related classes"
[lhc/web/wiklou.git] / includes / widget / search / FullSearchResultWidget.php
index af1e027..f648535 100644 (file)
@@ -6,6 +6,7 @@ use Category;
 use Hooks;
 use HtmlArmor;
 use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\MediaWikiServices;
 use SearchResult;
 use SpecialSearch;
 use Title;
@@ -30,7 +31,7 @@ class FullSearchResultWidget implements SearchResultWidget {
 
        /**
         * @param SearchResult $result The result to render
-        * @param string $terms Terms to be highlighted (@see SearchResult::getTextSnippet)
+        * @param string[] $terms Terms to be highlighted (@see SearchResult::getTextSnippet)
         * @param int $position The result position, including offset
         * @return string HTML
         */
@@ -47,7 +48,10 @@ class FullSearchResultWidget implements SearchResultWidget {
                // This is not quite safe, but better than showing excerpts from
                // non-readable pages. Note that hiding the entry entirely would
                // screw up paging (really?).
-               if ( !$result->getTitle()->userCan( 'read', $this->specialPage->getUser() ) ) {
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+               if ( !$permissionManager->userCan(
+                       'read', $this->specialPage->getUser(), $result->getTitle()
+               ) ) {
                        return "<li>{$link}</li>";
                }
 
@@ -107,7 +111,7 @@ class FullSearchResultWidget implements SearchResultWidget {
                                "</table>";
                }
 
-               return "<li>{$html}</li>";
+               return "<li class='mw-search-result'>{$html}</li>";
        }
 
        /**
@@ -117,7 +121,7 @@ class FullSearchResultWidget implements SearchResultWidget {
         * title with highlighted words).
         *
         * @param SearchResult $result
-        * @param string $terms
+        * @param string[] $terms
         * @param int $position
         * @return string HTML
         */
@@ -248,7 +252,8 @@ class FullSearchResultWidget implements SearchResultWidget {
                $descHtml = null;
                $thumbHtml = null;
 
-               $img = $result->getFile() ?: wfFindFile( $title );
+               $img = $result->getFile() ?: MediaWikiServices::getInstance()->getRepoGroup()
+                       ->findFile( $title );
                if ( $img ) {
                        $thumb = $img->transform( [ 'width' => 120, 'height' => 120 ] );
                        if ( $thumb ) {