Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / search / SqlSearchResultSet.php
index 022dc0a..87068ca 100644 (file)
@@ -1,25 +1,37 @@
 <?php
 
-use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IResultWrapper;
 
 /**
  * This class is used for different SQL-based search engines shipped with MediaWiki
  * @ingroup Search
  */
 class SqlSearchResultSet extends SearchResultSet {
-       /** @var ResultWrapper Result object from database */
+       /** @noinspection PhpMissingParentConstructorInspection */
+
+       /** @var IResultWrapper Result object from database */
        protected $resultSet;
-       /** @var string Requested search query */
+       /** @var string[] Requested search query */
        protected $terms;
        /** @var int|null Total number of hits for $terms */
        protected $totalHits;
 
-       function __construct( ResultWrapper $resultSet, $terms, $total = null ) {
+       /**
+        * @param IResultWrapper $resultSet
+        * @param string[] $terms
+        * @param int|null $total
+        */
+       function __construct( IResultWrapper $resultSet, array $terms, $total = null ) {
+               parent::__construct();
                $this->resultSet = $resultSet;
                $this->terms = $terms;
                $this->totalHits = $total;
        }
 
+       /**
+        * @return string[]
+        * @deprecated since 1.34
+        */
        function termMatches() {
                return $this->terms;
        }
@@ -40,10 +52,15 @@ class SqlSearchResultSet extends SearchResultSet {
                if ( $this->results === null ) {
                        $this->results = [];
                        $this->resultSet->rewind();
+                       $terms = \MediaWiki\MediaWikiServices::getInstance()->getContentLanguage()
+                               ->convertForSearchResult( $this->terms );
                        while ( ( $row = $this->resultSet->fetchObject() ) !== false ) {
-                               $this->results[] = SearchResult::newFromTitle(
-                                       Title::makeTitle( $row->page_namespace, $row->page_title ), $this
+                               $result = new SqlSearchResult(
+                                       Title::makeTitle( $row->page_namespace, $row->page_title ),
+                                       $terms
                                );
+                               $this->augmentResult( $result );
+                               $this->results[] = $result;
                        }
                }
                return $this->results;
@@ -51,7 +68,7 @@ class SqlSearchResultSet extends SearchResultSet {
 
        function free() {
                if ( $this->resultSet === false ) {
-                       return false;
+                       return;
                }
 
                $this->resultSet->free();