39 parent::__construct( $main, $action );
41 $this->revisionStore = $revisionStore;
42 $this->changeTagsStore = $changeTagsStore;
43 $this->recentChangeLookup = $recentChangeLookup;
54 $block = $user->getBlock();
55 if ( $block && $block->isSitewide() ) {
60 if ( $params[
'tags'] ) {
61 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
62 if ( !$ableToTag->isOK() ) {
70 if ( $params[
'revid'] ) {
71 foreach ( $params[
'revid'] as $id ) {
75 if ( $params[
'rcid'] ) {
76 foreach ( $params[
'rcid'] as $id ) {
80 if ( $params[
'logid'] ) {
81 foreach ( $params[
'logid'] as $id ) {
91 $result = $this->dbr->newSelectQueryBuilder()
94 ->where( [
'log_id' => $logid ] )
95 ->caller( __METHOD__ )->fetchField();
101 $idResult = [ $type => $id ];
107 $valid = $this->recentChangeLookup->getRecentChangeById( $id );
109 if ( $valid && $this->getPermissionManager()->isBlockedFrom( $user, $valid->getTitle() ) ) {
110 $idResult[
'status'] =
'error';
116 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
122 $valid = $this->revisionStore->getRevisionById( $id );
126 $this->getPermissionManager()->isBlockedFrom( $user, $valid->getPageAsLinkTarget() )
128 $idResult[
'status'] =
'error';
134 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
140 $valid = $this->validateLogId( $id );
145 $idResult[
'status'] =
'error';
147 $idResult += $this->getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
151 $status = ChangeTags::updateTagsWithChecks( $params[
'add'],
153 ( $type ===
'rcid' ? $id : null ),
154 ( $type ===
'revid' ? $id : null ),
155 ( $type ===
'logid' ? $id : null ),
161 if ( !$status->isOK() ) {
162 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
163 $idResult[
'status'] =
'skipped';
165 $idResult[
'status'] =
'failure';
166 $idResult[
'errors'] = $this->getErrorFormatter()->arrayFromStatus( $status,
'error' );
169 $idResult[
'status'] =
'success';
170 if ( $status->value->logId ===
null ) {
171 $idResult[
'noop'] =
true;
173 $idResult[
'actionlogid'] = $status->value->logId;
174 $idResult[
'added'] = $status->value->addedTags;
176 $idResult[
'removed'] = $status->value->removedTags;
179 if ( $params[
'tags'] ) {
180 $this->changeTagsStore->addTags( $params[
'tags'],
null,
null, $status->value->logId );
201 ParamValidator::PARAM_TYPE =>
'integer',
202 ParamValidator::PARAM_ISMULTI =>
true,
205 ParamValidator::PARAM_TYPE =>
'integer',
206 ParamValidator::PARAM_ISMULTI =>
true,
209 ParamValidator::PARAM_TYPE =>
'integer',
210 ParamValidator::PARAM_ISMULTI =>
true,
213 ParamValidator::PARAM_TYPE =>
'tags',
214 ParamValidator::PARAM_ISMULTI =>
true,
217 ParamValidator::PARAM_TYPE =>
'string',
218 ParamValidator::PARAM_ISMULTI =>
true,
221 ParamValidator::PARAM_TYPE =>
'string',
222 ParamValidator::PARAM_DEFAULT =>
'',
225 ParamValidator::PARAM_TYPE =>
'tags',
226 ParamValidator::PARAM_ISMULTI =>
true,
239 'action=tag&revid=123&add=vandalism&token=123ABC'
240 =>
'apihelp-tag-example-rev',
241 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
242 =>
'apihelp-tag-example-log',
248 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
253class_alias( ApiTag::class,
'ApiTag' );
This is the main API class, used for both external and internal processing.