Adds a tags parameter. This allows a user with the applychangetags right to tag the log entry corresponding to the action.
Bug: T97720
Change-Id: I11418d22ee780944e92d82e32b271b8276c396bf
'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();
$comment = wfMessage(
'rotate-comment'
)->numParams( $rotation )->inContentLanguage()->text();
- $status = $file->upload( $dstPath,
- $comment, $comment, 0, false, false, $this->getUser() );
+ $status = $file->upload(
+ $dstPath,
+ $comment,
+ $comment,
+ 0,
+ false,
+ false,
+ $this->getUser(),
+ $params['tags'] ?: []
+ );
if ( $status->isGood() ) {
$r['result'] = 'Success';
} else {
'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 );
$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 ) ) {
$list = RevisionDeleter::createList(
$params['type'], $this->getContext(), $targetObj, $params['ids']
);
- $status = $list->setVisibility(
- [ 'value' => $bitfield, 'comment' => $params['reason'], 'perItemStatus' => true ]
- );
+ $status = $list->setVisibility( [
+ 'value' => $bitfield,
+ 'comment' => $params['reason'],
+ 'perItemStatus' => true,
+ 'tags' => $params['tags']
+ ] );
$result = $this->getResult();
$data = $this->extractStatusInfo( $status );
ApiBase::PARAM_DFLT => 'nochange',
],
'reason' => null,
+ 'tags' => [
+ ApiBase::PARAM_TYPE => 'tags',
+ ApiBase::PARAM_ISMULTI => true,
+ ],
];
}
$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 = [];
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;
'reason' => [
ApiBase::PARAM_DFLT => '',
],
+ 'tags' => [
+ ApiBase::PARAM_TYPE => 'tags',
+ ApiBase::PARAM_ISMULTI => true,
+ ],
];
}
"apihelp-imagerotate-description": "Rotate one or more images.",
"apihelp-imagerotate-param-rotation": "Degrees to rotate image clockwise.",
+ "apihelp-imagerotate-param-tags": "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.",
"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": "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>.",
"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>",
"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}}",
"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}}",
"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}}",
*
* @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 change tags to apply to the log entry
* @return Status
* @since 1.23 Added 'perItemStatus' param
*/
'comment' => $comment,
'ids' => $idsForLog,
'authorIds' => $authorIds,
- 'authorIPs' => $authorIPs
+ 'authorIPs' => $authorIPs,
+ 'tags' => isset( $params['tags'] ) ? $params['tags'] : [],
]
);
* 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 change tags to apply to the log entry
* @throws MWException
*/
private function updateLog( $logType, $params ) {
'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 );
}