36 parent::__construct( $main, $action );
48 $block = $user->getBlock();
49 if ( $block && $block->isSitewide() ) {
54 if ( $params[
'tags'] ) {
55 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
56 if ( !$ableToTag->isOK() ) {
64 if ( $params[
'revid'] ) {
65 foreach ( $params[
'revid'] as $id ) {
69 if ( $params[
'rcid'] ) {
70 foreach ( $params[
'rcid'] as $id ) {
74 if ( $params[
'logid'] ) {
75 foreach ( $params[
'logid'] as $id ) {
85 $result = $this->dbr->newSelectQueryBuilder()
88 ->where( [
'log_id' => $logid ] )
89 ->caller( __METHOD__ )->fetchField();
95 $idResult = [ $type => $id ];
101 $valid = $this->recentChangeLookup->getRecentChangeById( $id );
103 if ( $valid && $this->getPermissionManager()->isBlockedFrom( $user, $valid->getTitle() ) ) {
104 $idResult[
'status'] =
'error';
110 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
116 $valid = $this->revisionStore->getRevisionById( $id );
120 $this->getPermissionManager()->isBlockedFrom( $user, $valid->getPageAsLinkTarget() )
122 $idResult[
'status'] =
'error';
128 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
134 $valid = $this->validateLogId( $id );
139 $idResult[
'status'] =
'error';
141 $idResult += $this->getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
145 $status = ChangeTags::updateTagsWithChecks( $params[
'add'],
147 ( $type ===
'rcid' ? $id : null ),
148 ( $type ===
'revid' ? $id : null ),
149 ( $type ===
'logid' ? $id : null ),
155 if ( !$status->isOK() ) {
156 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
157 $idResult[
'status'] =
'skipped';
159 $idResult[
'status'] =
'failure';
160 $idResult[
'errors'] = $this->getErrorFormatter()->arrayFromStatus( $status,
'error' );
163 $idResult[
'status'] =
'success';
164 if ( $status->value->logId ===
null ) {
165 $idResult[
'noop'] =
true;
167 $idResult[
'actionlogid'] = $status->value->logId;
168 $idResult[
'added'] = $status->value->addedTags;
170 $idResult[
'removed'] = $status->value->removedTags;
173 if ( $params[
'tags'] ) {
174 $this->changeTagsStore->addTags( $params[
'tags'],
null,
null, $status->value->logId );
195 ParamValidator::PARAM_TYPE =>
'integer',
196 ParamValidator::PARAM_ISMULTI =>
true,
199 ParamValidator::PARAM_TYPE =>
'integer',
200 ParamValidator::PARAM_ISMULTI =>
true,
203 ParamValidator::PARAM_TYPE =>
'integer',
204 ParamValidator::PARAM_ISMULTI =>
true,
207 ParamValidator::PARAM_TYPE =>
'tags',
208 ParamValidator::PARAM_ISMULTI =>
true,
211 ParamValidator::PARAM_TYPE =>
'string',
212 ParamValidator::PARAM_ISMULTI =>
true,
215 ParamValidator::PARAM_TYPE =>
'string',
216 ParamValidator::PARAM_DEFAULT =>
'',
219 ParamValidator::PARAM_TYPE =>
'tags',
220 ParamValidator::PARAM_ISMULTI =>
true,
233 'action=tag&revid=123&add=vandalism&token=123ABC'
234 =>
'apihelp-tag-example-rev',
235 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
236 =>
'apihelp-tag-example-log',
242 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
247class_alias( ApiTag::class,
'ApiTag' );
This is the main API class, used for both external and internal processing.