diff --git a/extension.json b/extension.json index 5178a929..b04fcf1b 100644 --- a/extension.json +++ b/extension.json @@ -14,6 +14,7 @@ "MediaWiki\\Linter\\LintError": "includes/LintError.php", "MediaWiki\\Linter\\ApiRecordLint": "includes/ApiRecordLint.php", "MediaWiki\\Linter\\ApiQueryLintErrors": "includes/ApiQueryLintErrors.php", + "MediaWiki\\Linter\\ApiQueryLinterStats": "includes/ApiQueryLinterStats.php", "MediaWiki\\Linter\\RecordLintJob": "includes/RecordLintJob.php", "MediaWiki\\Linter\\SpecialLintErrors": "includes/SpecialLintErrors.php", "MediaWiki\\Linter\\LintErrorsPager": "includes/LintErrorsPager.php", @@ -38,6 +39,9 @@ "APIListModules": { "linterrors": "MediaWiki\\Linter\\ApiQueryLintErrors" }, + "APIMetaModules": { + "linterstats": "MediaWiki\\Linter\\ApiQueryLinterStats" + }, "SpecialPages": { "LintErrors": "MediaWiki\\Linter\\SpecialLintErrors" }, diff --git a/i18n/en.json b/i18n/en.json index 98a02770..5a145e6b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -54,5 +54,7 @@ "apihelp-record-lint-description": "Record a lint error in the database", "apihelp-record-lint-param-data": "JSON encoded data about the error", "apihelp-record-lint-param-page": "Page title", - "apihelp-record-lint-param-revision": "Revision ID that the error was found in" + "apihelp-record-lint-param-revision": "Revision ID that the error was found in", + "apihelp-query+linterstats-description": "Get number of lint errors in each category", + "apihelp-query+linterstats-example-1": "Get number of lint errors in each category" } diff --git a/i18n/qqq.json b/i18n/qqq.json index 106b5965..6b4e555f 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -57,5 +57,8 @@ "apihelp-record-lint-description": "{{doc-apihelp-description|record-lint}}", "apihelp-record-lint-param-data": "{{doc-apihelp-param|record-lint|data}}", "apihelp-record-lint-param-page": "{{doc-apihelp-param|record-lint|page}}\n{{Identical|Page title}}", - "apihelp-record-lint-param-revision": "{{doc-apihelp-param|record-lint|revision}}" + "apihelp-record-lint-param-revision": "{{doc-apihelp-param|record-lint|revision}}", + "apihelp-query+linterstats-description": "{{doc-apihelp-description|query+linterstats}}", + "apihelp-query+linterstats-example-1": "{{doc-apihelp-example|query+linterstats}}" + } diff --git a/includes/ApiQueryLinterStats.php b/includes/ApiQueryLinterStats.php new file mode 100644 index 00000000..6f716ed3 --- /dev/null +++ b/includes/ApiQueryLinterStats.php @@ -0,0 +1,52 @@ +getMainWANObjectCache() + ); + + $totals = $totalsLookup->getTotals(); + ApiResult::setArrayType( $totals, 'assoc' ); + $this->getResult()->addValue( [ 'query', 'linterstats' ], 'totals', $totals ); + } + + public function getExamplesMessages() { + return [ + 'action=query&meta=linterstats' => + 'apihelp-query+linterstats-example-1', + ]; + } +}