/** @var int */
protected $offset = 0;
- /** @var array|string */
+ /** @var string[] */
protected $searchTerms = [];
/** @var bool */
* be converted to final in 1.34. Override self::doSearchArchiveTitle().
*
* @param string $term Raw search term
- * @return Status<Title[]>
+ * @return Status
* @since 1.29
*/
public function searchArchiveTitle( $term ) {
* Perform a title search in the article archive.
*
* @param string $term Raw search term
- * @return Status<Title[]>
+ * @return Status
* @since 1.32
*/
protected function doSearchArchiveTitle( $term ) {
*/
protected function initFromTitle( $title ) {
$this->mTitle = $title;
+ $services = MediaWikiServices::getInstance();
if ( !is_null( $this->mTitle ) ) {
$id = false;
Hooks::run( 'SearchResultInitFromTitle', [ $title, &$id ] );
$this->mRevision = Revision::newFromTitle(
$this->mTitle, $id, Revision::READ_NORMAL );
if ( $this->mTitle->getNamespace() === NS_FILE ) {
- $this->mImage = wfFindFile( $this->mTitle );
+ $this->mImage = $services->getRepoGroup()->findFile( $this->mTitle );
}
}
- $this->searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
+ $this->searchEngine = $services->newSearchEngine();
}
/**
}
/**
- * @param array $terms Terms to highlight
+ * @param string[] $terms Terms to highlight
* @return string Highlighted text snippet, null (and not '') if not supported
*/
function getTextSnippet( $terms ) {
<?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 ) {
+ function __construct( IResultWrapper $resultSet, $terms, $total = null ) {
$this->resultSet = $resultSet;
$this->terms = $terms;
$this->totalHits = $total;
function free() {
if ( $this->resultSet === false ) {
- return false;
+ return;
}
$this->resultSet->free();
use Hooks;
use HtmlArmor;
use MediaWiki\Linker\LinkRenderer;
+use MediaWiki\MediaWikiServices;
use SearchResult;
use SpecialSearch;
use Title;
/**
* @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
*/
// 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>";
}
* title with highlighted words).
*
* @param SearchResult $result
- * @param string $terms
+ * @param string[] $terms
* @param int $position
* @return string HTML
*/
$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 ) {