MtDu has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/329653 )
Change subject: Add tags support to the following API modules ...................................................................... Add tags support to the following API modules * imagerotate * revisiondelete * tag Bug: T97720 Change-Id: I11418d22ee780944e92d82e32b271b8276c396bf --- M includes/api/ApiImageRotate.php M includes/api/ApiRevisionDelete.php M includes/api/ApiTag.php M includes/api/i18n/en.json M includes/api/i18n/qqq.json M includes/revisiondelete/RevDelList.php 6 files changed, 55 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/53/329653/1 diff --git a/includes/api/ApiImageRotate.php b/includes/api/ApiImageRotate.php index 72fb16d..92ac745 100644 --- a/includes/api/ApiImageRotate.php +++ b/includes/api/ApiImageRotate.php @@ -42,6 +42,14 @@ 'invalidTitles', 'special', 'missingIds', 'missingRevIds', 'interwikiTitles', ] ); + // Check if user can add tags + if ( count( $params['tags'] ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $this->getUser() ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } + } + foreach ( $pageSet->getTitles() as $title ) { $r = []; $r['id'] = $title->getArticleID(); @@ -105,7 +113,7 @@ 'rotate-comment' )->numParams( $rotation )->inContentLanguage()->text(); $status = $file->upload( $dstPath, - $comment, $comment, 0, false, false, $this->getUser() ); + $comment, $comment, 0, false, false, $this->getUser(), $params['tags'] ?: [] ); if ( $status->isGood() ) { $r['result'] = 'Success'; } else { @@ -157,6 +165,10 @@ 'continue' => [ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', ], + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; if ( $flags ) { $result += $this->getPageSet()->getFinalParams( $flags ); diff --git a/includes/api/ApiRevisionDelete.php b/includes/api/ApiRevisionDelete.php index 763aef5..1748eb9 100644 --- a/includes/api/ApiRevisionDelete.php +++ b/includes/api/ApiRevisionDelete.php @@ -46,6 +46,14 @@ $this->dieWithError( [ 'apierror-paramempty', 'ids' ], 'paramempty_ids' ); } + // Check if user can add tags + if ( count( $params['tags'] ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); + if ( !$ableToTag->isOK() ) { + $this->dieStatus( $ableToTag ); + } + } + $hide = $params['hide'] ?: []; $show = $params['show'] ?: []; if ( array_intersect( $hide, $show ) ) { @@ -91,7 +99,7 @@ $params['type'], $this->getContext(), $targetObj, $params['ids'] ); $status = $list->setVisibility( - [ 'value' => $bitfield, 'comment' => $params['reason'], 'perItemStatus' => true ] + [ 'value' => $bitfield, 'comment' => $params['reason'], 'perItemStatus' => true, 'tags' => $params['tags'] ] ); $result = $this->getResult(); @@ -165,6 +173,10 @@ ApiBase::PARAM_DFLT => 'nochange', ], 'reason' => null, + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; } diff --git a/includes/api/ApiTag.php b/includes/api/ApiTag.php index b142900..7470ff3 100644 --- a/includes/api/ApiTag.php +++ b/includes/api/ApiTag.php @@ -36,6 +36,14 @@ $this->dieBlocked( $user->getBlock() ); } + // Check if user can add tags + if ( count( $params['tags'] ) ) { + $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); + if ( !$ableToTag->isOk() ) { + $this->dieStatus( $ableToTag ); + } + } + // validate and process each revid, rcid and logid $this->requireAtLeastOneParameter( $params, 'revid', 'rcid', 'logid' ); $ret = []; @@ -116,6 +124,10 @@ ApiResult::setIndexedTagName( $idResult['added'], 't' ); $idResult['removed'] = $status->value->removedTags; ApiResult::setIndexedTagName( $idResult['removed'], 't' ); + + if ( $params['tags'] ) { + ChangeTags::addTags( $params['tags'], null, null, $status->value->logId ); + } } } return $idResult; @@ -154,6 +166,10 @@ 'reason' => [ ApiBase::PARAM_DFLT => '', ], + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', + ApiBase::PARAM_ISMULTI => true, + ], ]; } diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index f6eeffe..f3ebb75 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -218,6 +218,7 @@ "apihelp-imagerotate-description": "Rotate one or more images.", "apihelp-imagerotate-param-rotation": "Degrees to rotate image clockwise.", + "apihelp-imagerotate-param-tags": "Change tags to apply to the entry in the upload log.", "apihelp-imagerotate-example-simple": "Rotate <kbd>File:Example.png</kbd> by <kbd>90</kbd> degrees.", "apihelp-imagerotate-example-generator": "Rotate all images in <kbd>Category:Flip</kbd> by <kbd>180</kbd> degrees.", @@ -1326,6 +1327,7 @@ "apihelp-revisiondelete-param-show": "What to unhide for each revision.", "apihelp-revisiondelete-param-suppress": "Whether to suppress data from administrators as well as others.", "apihelp-revisiondelete-param-reason": "Reason for the deletion or undeletion.", + "apihelp-revisiondelete-param-tags": "Change tags to apply to the entry in the deletion log.", "apihelp-revisiondelete-example-revision": "Hide content for revision <kbd>12345</kbd> on the page <kbd>Main Page</kbd>.", "apihelp-revisiondelete-example-log": "Hide all data on log entry <kbd>67890</kbd> with the reason <kbd>BLP violation</kbd>.", @@ -1371,6 +1373,7 @@ "apihelp-tag-param-add": "Tags to add. Only manually defined tags can be added.", "apihelp-tag-param-remove": "Tags to remove. Only tags that are either manually defined or completely undefined can be removed.", "apihelp-tag-param-reason": "Reason for the change.", + "apihelp-tag-param-tags": "Tags to apply to the log entry that will be created as a result of this action.", "apihelp-tag-example-rev": "Add the <kbd>vandalism</kbd> tag to revision ID 123 without specifying a reason", "apihelp-tag-example-log": "Remove the <kbd>spam</kbd> tag from log entry ID 123 with the reason <kbd>Wrongly applied</kbd>", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 2c6637c..6a9b360 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -211,6 +211,7 @@ "apihelp-help-example-query": "{{doc-apihelp-example|help}}", "apihelp-imagerotate-description": "{{doc-apihelp-description|imagerotate}}", "apihelp-imagerotate-param-rotation": "{{doc-apihelp-param|imagerotate|rotation}}", + "apihelp-imagerotate-param-tags": "{{doc-apihelp-param|imagerotate|tags}}", "apihelp-imagerotate-example-simple": "{{doc-apihelp-example|imagerotate}}", "apihelp-imagerotate-example-generator": "{{doc-apihelp-example|imagerotate}}", "apihelp-import-description": "{{doc-apihelp-description|import}}", @@ -1238,6 +1239,7 @@ "apihelp-revisiondelete-param-show": "{{doc-apihelp-param|revisiondelete|show}}", "apihelp-revisiondelete-param-suppress": "{{doc-apihelp-param|revisiondelete|suppress}}", "apihelp-revisiondelete-param-reason": "{{doc-apihelp-param|revisiondelete|reason}}", + "apihelp-revisiondelete-param-tags": "{{doc-apihelp-param|revisiondelete|tags}}", "apihelp-revisiondelete-example-revision": "{{doc-apihelp-example|revisiondelete}}", "apihelp-revisiondelete-example-log": "{{doc-apihelp-example|revisiondelete}}", "apihelp-rollback-description": "{{doc-apihelp-description|rollback}}", @@ -1278,6 +1280,7 @@ "apihelp-tag-param-add": "{{doc-apihelp-param|tag|add}}", "apihelp-tag-param-remove": "{{doc-apihelp-param|tag|remove}}", "apihelp-tag-param-reason": "{{doc-apihelp-param|tag|reason}}", + "apihelp-tag-param-tags": "{{doc-apihelp-param|tag|tags}}", "apihelp-tag-example-rev": "{{doc-apihelp-example|tag}}", "apihelp-tag-example-log": "{{doc-apihelp-example|tag}}", "apihelp-tokens-description": "{{doc-apihelp-description|tokens}}", diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index 674846d..78612c7 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -97,8 +97,9 @@ * * @param array $params Associative array of parameters. Members are: * value: ExtractBitParams() bitfield array - * comment: The log comment. + * comment: The log comment * perItemStatus: Set if you want per-item status reports + * tags: The array of tags to apply to the log entry * @return Status * @since 1.23 Added 'perItemStatus' param */ @@ -269,7 +270,8 @@ 'comment' => $comment, 'ids' => $idsForLog, 'authorIds' => $authorIds, - 'authorIPs' => $authorIPs + 'authorIPs' => $authorIPs, + 'tags' => isset( $params['tags'] ) ? $params['tags'] : [], ] ); @@ -327,6 +329,7 @@ * comment: The log comment * authorsIds: The array of the user IDs of the offenders * authorsIPs: The array of the IP/anon user offenders + * tags: The array of tags to apply to the log entry * @throws MWException */ private function updateLog( $logType, $params ) { @@ -349,6 +352,8 @@ 'target_author_id' => $params['authorIds'], 'target_author_ip' => $params['authorIPs'], ] ); + // Apply change tags to the log entry + $logEntry->setTags( $params['tags'] ); $logId = $logEntry->insert(); $logEntry->publish( $logId ); } -- To view, visit https://gerrit.wikimedia.org/r/329653 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I11418d22ee780944e92d82e32b271b8276c396bf Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits