X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuerySearch.php;h=9228d9ace91f53240e3219a13ef8105b986adfcc;hb=18c2d20c54f9851af639cb24603493ca197baaa8;hp=98c65516c9f772ed98150c6bcd277c2acd7400b4;hpb=284778405b0e41c57b3085958401e07b6ca742e6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 98c65516c9..9228d9ace9 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -20,8 +20,6 @@ * @file */ -use MediaWiki\MediaWikiServices; - /** * Query module to perform full text search within wiki titles and content * @@ -145,9 +143,6 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } } - // Add the search results to the result - $terms = MediaWikiServices::getInstance()->getContentLanguage()-> - convertForSearchResult( $matches->termMatches() ); $titles = []; $count = 0; @@ -163,7 +158,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } if ( $resultPageSet === null ) { - $vals = $this->getSearchResultData( $result, $prop, $terms ); + $vals = $this->getSearchResultData( $result, $prop ); if ( $vals ) { // Add item to results and see whether it fits $fit = $apiResult->addValue( [ 'query', $this->getModuleName() ], null, $vals ); @@ -184,14 +179,14 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { // Interwiki results inside main result set $canAddInterwiki = (bool)$params['enablerewrites'] && ( $resultPageSet === null ); if ( $canAddInterwiki ) { - $this->addInterwikiResults( $matches, $apiResult, $prop, $terms, 'additional', - SearchResultSet::INLINE_RESULTS ); + $this->addInterwikiResults( $matches, $apiResult, $prop, 'additional', + ISearchResultSet::INLINE_RESULTS ); } // Interwiki results outside main result set if ( $interwiki && $resultPageSet === null ) { - $this->addInterwikiResults( $matches, $apiResult, $prop, $terms, 'interwiki', - SearchResultSet::SECONDARY_RESULTS ); + $this->addInterwikiResults( $matches, $apiResult, $prop, 'interwiki', + ISearchResultSet::SECONDARY_RESULTS ); } if ( $resultPageSet === null ) { @@ -217,10 +212,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { * Assemble search result data. * @param SearchResult $result Search result * @param array $prop Props to extract (as keys) - * @param array $terms Terms list * @return array|null Result data or null if result is broken in some way. */ - private function getSearchResultData( SearchResult $result, $prop, $terms ) { + private function getSearchResultData( SearchResult $result, $prop ) { // Silently skip broken and missing titles if ( $result->isBrokenTitle() || $result->isMissingRevision() ) { return null; @@ -239,7 +233,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $vals['wordcount'] = $result->getWordCount(); } if ( isset( $prop['snippet'] ) ) { - $vals['snippet'] = $result->getTextSnippet( $terms ); + $vals['snippet'] = $result->getTextSnippet(); } if ( isset( $prop['timestamp'] ) ) { $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $result->getTimestamp() ); @@ -284,17 +278,16 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { /** * Add interwiki results as a section in query results. - * @param SearchResultSet $matches + * @param ISearchResultSet $matches * @param ApiResult $apiResult * @param array $prop Props to extract (as keys) - * @param array $terms Terms list * @param string $section Section name where results would go * @param int $type Interwiki result type * @return int|null Number of total hits in the data or null if none was produced */ private function addInterwikiResults( - SearchResultSet $matches, ApiResult $apiResult, $prop, - $terms, $section, $type + ISearchResultSet $matches, ApiResult $apiResult, $prop, + $section, $type ) { $totalhits = null; if ( $matches->hasInterwikiResults( $type ) ) { @@ -304,7 +297,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { foreach ( $interwikiMatches as $result ) { $title = $result->getTitle(); - $vals = $this->getSearchResultData( $result, $prop, $terms ); + $vals = $this->getSearchResultData( $result, $prop ); $vals['namespace'] = $result->getInterwikiNamespaceText(); $vals['title'] = $title->getText();