58 parent::__construct( $main, $action );
60 $this->revisionStore = $revisionStore;
61 $this->changeTagsStore = $changeTagsStore;
72 $block = $user->getBlock();
73 if ( $block && $block->isSitewide() ) {
80 if ( !$ableToTag->isOK() ) {
89 foreach (
$params[
'revid'] as $id ) {
94 foreach (
$params[
'rcid'] as $id ) {
99 foreach (
$params[
'logid'] as $id ) {
109 $result = $this->dbr->newSelectQueryBuilder()
112 ->where( [
'log_id' => $logid ] )
113 ->caller( __METHOD__ )->fetchField();
114 return (
bool)$result;
119 $idResult = [ $type => $id ];
125 $valid = RecentChange::newFromId( $id );
128 $idResult[
'status'] =
'error';
134 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
140 $valid = $this->revisionStore->getRevisionById( $id );
146 $idResult[
'status'] =
'error';
152 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
163 $idResult[
'status'] =
'error';
165 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
171 ( $type ===
'rcid' ? $id : null ),
172 ( $type ===
'revid' ? $id : null ),
173 ( $type ===
'logid' ? $id : null ),
179 if ( !$status->isOK() ) {
180 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
181 $idResult[
'status'] =
'skipped';
183 $idResult[
'status'] =
'failure';
184 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
187 $idResult[
'status'] =
'success';
188 if ( $status->value->logId ===
null ) {
189 $idResult[
'noop'] =
true;
191 $idResult[
'actionlogid'] = $status->value->logId;
192 $idResult[
'added'] = $status->value->addedTags;
194 $idResult[
'removed'] = $status->value->removedTags;
198 $this->changeTagsStore->addTags(
$params[
'tags'],
null,
null, $status->value->logId );
216 ParamValidator::PARAM_TYPE =>
'integer',
217 ParamValidator::PARAM_ISMULTI =>
true,
220 ParamValidator::PARAM_TYPE =>
'integer',
221 ParamValidator::PARAM_ISMULTI =>
true,
224 ParamValidator::PARAM_TYPE =>
'integer',
225 ParamValidator::PARAM_ISMULTI =>
true,
228 ParamValidator::PARAM_TYPE =>
'tags',
229 ParamValidator::PARAM_ISMULTI =>
true,
232 ParamValidator::PARAM_TYPE =>
'string',
233 ParamValidator::PARAM_ISMULTI =>
true,
236 ParamValidator::PARAM_TYPE =>
'string',
237 ParamValidator::PARAM_DEFAULT =>
'',
240 ParamValidator::PARAM_TYPE =>
'tags',
241 ParamValidator::PARAM_ISMULTI =>
true,
252 'action=tag&revid=123&add=vandalism&token=123ABC'
253 =>
'apihelp-tag-example-rev',
254 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
255 =>
'apihelp-tag-example-log',
260 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
265class_alias( ApiTag::class,
'ApiTag' );
array $params
The job parameters.
This is the main API class, used for both external and internal processing.
Utility class for creating and reading rows in the recentchanges table.