Merge "[DI] Use dependency injection for ApiQueryLinterStats"

This commit is contained in:
jenkins-bot 2024-04-05 00:40:45 +00:00 committed by Gerrit Code Review
commit 0868dd1e83
2 changed files with 16 additions and 5 deletions

View file

@ -48,7 +48,12 @@
"linterrors": "MediaWiki\\Linter\\ApiQueryLintErrors"
},
"APIMetaModules": {
"linterstats": "MediaWiki\\Linter\\ApiQueryLinterStats"
"linterstats": {
"class": "MediaWiki\\Linter\\ApiQueryLinterStats",
"services": [
"MainWANObjectCache"
]
}
},
"SpecialPages": {
"LintErrors": {

View file

@ -22,14 +22,20 @@ namespace MediaWiki\Linter;
use ApiQuery;
use ApiQueryBase;
use ApiResult;
use MediaWiki\MediaWikiServices;
use WANObjectCache;
class ApiQueryLinterStats extends ApiQueryBase {
private WANObjectCache $cache;
/**
* @param ApiQuery $queryModule
* @param string $moduleName
* @param WANObjectCache $cache
*/
public function __construct( ApiQuery $queryModule ) {
parent::__construct( $queryModule, 'linterstats', 'lntrst' );
public function __construct( ApiQuery $queryModule, string $moduleName, WANObjectCache $cache ) {
parent::__construct( $queryModule, $moduleName, 'lntrst' );
$this->cache = $cache;
}
/**
@ -38,7 +44,7 @@ class ApiQueryLinterStats extends ApiQueryBase {
public function execute() {
$totalsLookup = new TotalsLookup(
new CategoryManager(),
MediaWikiServices::getInstance()->getMainWANObjectCache(),
$this->cache,
new Database( 0 )
);
$totals = $totalsLookup->getTotals();