mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
synced 2024-11-23 15:56:52 +00:00
ApiQueryExtracts: inject WikiPageFactory
Bug: T297688 Change-Id: I8faa8a14efcd6cb6b247301aa4da0c1abac7c97b
This commit is contained in:
parent
b7cb0703d9
commit
abcb71cabb
|
@ -19,7 +19,8 @@
|
|||
"services": [
|
||||
"ConfigFactory",
|
||||
"MainWANObjectCache",
|
||||
"LanguageConverterFactory"
|
||||
"LanguageConverterFactory",
|
||||
"WikiPageFactory"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -12,6 +12,7 @@ use FauxRequest;
|
|||
use MediaWiki\Languages\LanguageConverterFactory;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\WikiPageFactory;
|
||||
use ParserOptions;
|
||||
use Title;
|
||||
use User;
|
||||
|
@ -48,6 +49,10 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
* @var LanguageConverterFactory
|
||||
*/
|
||||
private $langConvFactory;
|
||||
/**
|
||||
* @var WikiPageFactory
|
||||
*/
|
||||
private $wikiPageFactory;
|
||||
|
||||
// TODO: Allow extensions to hook into this to opt-in.
|
||||
// This is partly for security reasons; see T107170.
|
||||
|
@ -62,18 +67,21 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
* @param ConfigFactory $configFactory
|
||||
* @param WANObjectCache $cache
|
||||
* @param LanguageConverterFactory $langConvFactory
|
||||
* @param WikiPageFactory $wikiPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
$query,
|
||||
$moduleName,
|
||||
ConfigFactory $configFactory,
|
||||
WANObjectCache $cache,
|
||||
LanguageConverterFactory $langConvFactory
|
||||
LanguageConverterFactory $langConvFactory,
|
||||
WikiPageFactory $wikiPageFactory
|
||||
) {
|
||||
parent::__construct( $query, $moduleName, self::PREFIX );
|
||||
$this->config = $configFactory->makeConfig( 'textextracts' );
|
||||
$this->cache = $cache;
|
||||
$this->langConvFactory = $langConvFactory;
|
||||
$this->wikiPageFactory = $wikiPageFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +174,7 @@ class ApiQueryExtracts extends ApiQueryBase {
|
|||
return '';
|
||||
}
|
||||
|
||||
$page = WikiPage::factory( $title );
|
||||
$page = $this->wikiPageFactory->newFromTitle( $title );
|
||||
|
||||
$introOnly = $this->params['intro'];
|
||||
$text = $this->getFromCache( $page, $introOnly );
|
||||
|
|
|
@ -53,7 +53,14 @@ class ApiQueryExtractsTest extends \MediaWikiIntegrationTestCase {
|
|||
$langConvFactory->method( 'getLanguageConverter' )
|
||||
->willReturn( $this->createMock( ILanguageConverter::class ) );
|
||||
|
||||
return new ApiQueryExtracts( $query, '', $configFactory, $cache, $langConvFactory );
|
||||
return new ApiQueryExtracts(
|
||||
$query,
|
||||
'',
|
||||
$configFactory,
|
||||
$cache,
|
||||
$langConvFactory,
|
||||
$this->getServiceContainer()->getWikiPageFactory()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMemCacheHelpers() {
|
||||
|
|
Loading…
Reference in a new issue