Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/322845
Change subject: API: Fix lntcategories parameter ...................................................................... API: Fix lntcategories parameter * Treat it as an array in all cases * Make the default value all categories * Rename from category to categories Bug: T151288 Change-Id: I5c0c341112894c5a7ec3aaebb6ac9085353f55bd --- M i18n/en.json M i18n/qqq.json M includes/ApiQueryLintErrors.php 3 files changed, 11 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter refs/changes/45/322845/1 diff --git a/i18n/en.json b/i18n/en.json index 66bd5fa..1771ae3 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -29,7 +29,7 @@ "linker-page-title-edit": "$1 ($2)", "linker-page-edit": "edit", "apihelp-query+linterrors-description": "Get a list of lint errors", - "apihelp-query+linterrors-param-category": "Category of lint errors", + "apihelp-query+linterrors-param-categories": "Categories of lint errors", "apihelp-query+linterrors-param-limit": "Number of results to query", "apihelp-query+linterrors-param-from": "Lint ID to start querying from", "apihelp-query+linterrors-param-namespace": "Only include lint errors from the specified namespaces", diff --git a/i18n/qqq.json b/i18n/qqq.json index 07d511a..564034f 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -31,7 +31,7 @@ "linker-page-title-edit": "Used in a table cell. $1 is a link to the page, $2 is a link to edit that page, the link text is {{msg-mw|linker-page-edit}}", "linker-page-edit": "Link text for edit link in {{msg-mw|linker-page-title-edit}} and {{msg-mw|linker-page-title-edit-template}}\n{{Identical|Edit}}", "apihelp-query+linterrors-description": "{{doc-apihelp-description|query+linterrors}}", - "apihelp-query+linterrors-param-category": "{{doc-apihelp-param|query+linterrors|category}}", + "apihelp-query+linterrors-param-categories": "{{doc-apihelp-param|query+linterrors|categories}}", "apihelp-query+linterrors-param-limit": "{{doc-apihelp-param|query+linterrors|limit}}", "apihelp-query+linterrors-param-from": "{{doc-apihelp-param|query+linterrors|from}}", "apihelp-query+linterrors-param-namespace": "{{doc-apihelp-param|query+linterrors|namespace}}", diff --git a/includes/ApiQueryLintErrors.php b/includes/ApiQueryLintErrors.php index 795a614..a305eb1 100644 --- a/includes/ApiQueryLintErrors.php +++ b/includes/ApiQueryLintErrors.php @@ -36,14 +36,9 @@ $categoryMgr = new CategoryManager(); $this->addTables( 'linter' ); - if ( $params['category'] !== null ) { - $this->addWhereFld( 'linter_cat', $categoryMgr->getCategoryId( $params['category'] ) ); - } else { - // Limit only to enabled categories (there might be others in the DB) - $this->addWhereFld( 'linter_cat', array_values( $categoryMgr->getCategoryIds( - $categoryMgr->getVisibleCategories() - ) ) ); - } + $this->addWhereFld( 'linter_cat', array_values( $categoryMgr->getCategoryIds( + $params['categories'] + ) ) ); $db = $this->getDB(); if ( $params['from'] !== null ) { $this->addWhere( 'linter_id >= ' . $db->addQuotes( $params['from'] ) ); @@ -94,10 +89,13 @@ } public function getAllowedParams() { + $visibleCats = ( new CategoryManager() )->getVisibleCategories(); return [ - 'category' => [ - ApiBase::PARAM_TYPE => ( new CategoryManager() )->getVisibleCategories(), + 'categories' => [ + ApiBase::PARAM_TYPE => $visibleCats, ApiBase::PARAM_ISMULTI => true, + // Default is to show all categories + ApiBase::PARAM_DFLT => implode( '|', $visibleCats ), ], 'limit' => [ ApiBase::PARAM_DFLT => 10, @@ -118,7 +116,7 @@ public function getExamplesMessages() { return [ - 'action=query&list=linterrors&lntcategory=obsolete-tag' => + 'action=query&list=linterrors&lntcategories=obsolete-tag' => 'apihelp-query+linterrors-example-1', ]; } -- To view, visit https://gerrit.wikimedia.org/r/322845 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5c0c341112894c5a7ec3aaebb6ac9085353f55bd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Linter Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits