51 parent::__construct( $main, $action );
53 $this->revisionStore = $revisionStore;
54 $this->changeTagsStore = $changeTagsStore;
65 $block = $user->getBlock();
66 if ( $block && $block->isSitewide() ) {
71 if ( $params[
'tags'] ) {
72 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
73 if ( !$ableToTag->isOK() ) {
81 if ( $params[
'revid'] ) {
82 foreach ( $params[
'revid'] as $id ) {
86 if ( $params[
'rcid'] ) {
87 foreach ( $params[
'rcid'] as $id ) {
91 if ( $params[
'logid'] ) {
92 foreach ( $params[
'logid'] as $id ) {
102 $result = $this->dbr->newSelectQueryBuilder()
105 ->where( [
'log_id' => $logid ] )
106 ->caller( __METHOD__ )->fetchField();
107 return (
bool)$result;
112 $idResult = [ $type => $id ];
118 $valid = RecentChange::newFromId( $id );
121 $idResult[
'status'] =
'error';
127 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
133 $valid = $this->revisionStore->getRevisionById( $id );
139 $idResult[
'status'] =
'error';
145 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
156 $idResult[
'status'] =
'error';
158 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
162 $status = ChangeTags::updateTagsWithChecks( $params[
'add'],
164 ( $type ===
'rcid' ? $id : null ),
165 ( $type ===
'revid' ? $id : null ),
166 ( $type ===
'logid' ? $id : null ),
172 if ( !$status->isOK() ) {
173 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
174 $idResult[
'status'] =
'skipped';
176 $idResult[
'status'] =
'failure';
177 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
180 $idResult[
'status'] =
'success';
181 if ( $status->value->logId ===
null ) {
182 $idResult[
'noop'] =
true;
184 $idResult[
'actionlogid'] = $status->value->logId;
185 $idResult[
'added'] = $status->value->addedTags;
187 $idResult[
'removed'] = $status->value->removedTags;
190 if ( $params[
'tags'] ) {
191 $this->changeTagsStore->addTags( $params[
'tags'],
null,
null, $status->value->logId );
209 ParamValidator::PARAM_TYPE =>
'integer',
210 ParamValidator::PARAM_ISMULTI =>
true,
213 ParamValidator::PARAM_TYPE =>
'integer',
214 ParamValidator::PARAM_ISMULTI =>
true,
217 ParamValidator::PARAM_TYPE =>
'integer',
218 ParamValidator::PARAM_ISMULTI =>
true,
221 ParamValidator::PARAM_TYPE =>
'tags',
222 ParamValidator::PARAM_ISMULTI =>
true,
225 ParamValidator::PARAM_TYPE =>
'string',
226 ParamValidator::PARAM_ISMULTI =>
true,
229 ParamValidator::PARAM_TYPE =>
'string',
230 ParamValidator::PARAM_DEFAULT =>
'',
233 ParamValidator::PARAM_TYPE =>
'tags',
234 ParamValidator::PARAM_ISMULTI =>
true,
245 'action=tag&revid=123&add=vandalism&token=123ABC'
246 =>
'apihelp-tag-example-rev',
247 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
248 =>
'apihelp-tag-example-log',
253 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
258class_alias( ApiTag::class,
'ApiTag' );
This is the main API class, used for both external and internal processing.