Replace deprecated WikiPage::factory in search related classes
Change-Id: I4f61e222bc9dfcc504491845ce165bd99c1b9b8c
This commit is contained in:
parent
b08b2d1518
commit
d2dd124e5b
2 changed files with 13 additions and 3 deletions
|
|
@ -21,6 +21,8 @@
|
|||
* @file
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* An utility class to rescore search results by looking for an exact match
|
||||
* in the db and add the page found to the first position.
|
||||
|
|
@ -135,7 +137,7 @@ class SearchExactMatchRescorer {
|
|||
* @return null|string If title exists and redirects, get the destination's prefixed name
|
||||
*/
|
||||
private function getRedirectTarget( $title ) {
|
||||
$page = WikiPage::factory( $title );
|
||||
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title );
|
||||
if ( !$page->exists() ) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use MediaWiki\HookContainer\HookContainer;
|
||||
use MediaWiki\HookContainer\HookRunner;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
|
||||
/**
|
||||
* Implementation of near match title search.
|
||||
|
|
@ -31,6 +32,11 @@ class SearchNearMatcher {
|
|||
*/
|
||||
private $hookRunner;
|
||||
|
||||
/**
|
||||
* @var WikiPageFactory
|
||||
*/
|
||||
private $wikiPageFactory;
|
||||
|
||||
/**
|
||||
* SearchNearMatcher constructor.
|
||||
* @param Config $config
|
||||
|
|
@ -40,8 +46,10 @@ class SearchNearMatcher {
|
|||
public function __construct( Config $config, Language $lang, HookContainer $hookContainer ) {
|
||||
$this->config = $config;
|
||||
$this->language = $lang;
|
||||
$this->languageConverter = MediaWikiServices::getInstance()->getLanguageConverterFactory()
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$this->languageConverter = $services->getLanguageConverterFactory()
|
||||
->getLanguageConverter( $lang );
|
||||
$this->wikiPageFactory = $services->getWikiPageFactory();
|
||||
$this->hookRunner = new HookRunner( $hookContainer );
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +122,7 @@ class SearchNearMatcher {
|
|||
}
|
||||
|
||||
# See if it still otherwise has content is some sane sense
|
||||
$page = WikiPage::factory( $title );
|
||||
$page = $this->wikiPageFactory->newFromTitle( $title );
|
||||
if ( $page->hasViewableContent() ) {
|
||||
return $title;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue