54 parent::__construct( $main, $action );
56 $this->revisionStore = $revisionStore;
57 $this->changeTagsStore = $changeTagsStore;
68 $block = $user->getBlock();
69 if ( $block && $block->isSitewide() ) {
74 if ( $params[
'tags'] ) {
76 if ( !$ableToTag->isOK() ) {
84 if ( $params[
'revid'] ) {
85 foreach ( $params[
'revid'] as $id ) {
89 if ( $params[
'rcid'] ) {
90 foreach ( $params[
'rcid'] as $id ) {
94 if ( $params[
'logid'] ) {
95 foreach ( $params[
'logid'] as $id ) {
105 $result = $this->dbr->newSelectQueryBuilder()
108 ->where( [
'log_id' => $logid ] )
109 ->caller( __METHOD__ )->fetchField();
110 return (
bool)$result;
115 $idResult = [ $type => $id ];
124 $idResult[
'status'] =
'error';
130 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
136 $valid = $this->revisionStore->getRevisionById( $id );
142 $idResult[
'status'] =
'error';
148 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
159 $idResult[
'status'] =
'error';
161 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
167 ( $type ===
'rcid' ? $id :
null ),
168 ( $type ===
'revid' ? $id :
null ),
169 ( $type ===
'logid' ? $id :
null ),
175 if ( !$status->isOK() ) {
176 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
177 $idResult[
'status'] =
'skipped';
179 $idResult[
'status'] =
'failure';
180 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
183 $idResult[
'status'] =
'success';
184 if ( $status->value->logId ===
null ) {
185 $idResult[
'noop'] =
true;
187 $idResult[
'actionlogid'] = $status->value->logId;
188 $idResult[
'added'] = $status->value->addedTags;
190 $idResult[
'removed'] = $status->value->removedTags;
193 if ( $params[
'tags'] ) {
194 $this->changeTagsStore->addTags( $params[
'tags'],
null,
null, $status->value->logId );
212 ParamValidator::PARAM_TYPE =>
'integer',
213 ParamValidator::PARAM_ISMULTI =>
true,
216 ParamValidator::PARAM_TYPE =>
'integer',
217 ParamValidator::PARAM_ISMULTI =>
true,
220 ParamValidator::PARAM_TYPE =>
'integer',
221 ParamValidator::PARAM_ISMULTI =>
true,
224 ParamValidator::PARAM_TYPE =>
'tags',
225 ParamValidator::PARAM_ISMULTI =>
true,
228 ParamValidator::PARAM_TYPE =>
'string',
229 ParamValidator::PARAM_ISMULTI =>
true,
232 ParamValidator::PARAM_TYPE =>
'string',
233 ParamValidator::PARAM_DEFAULT =>
'',
236 ParamValidator::PARAM_TYPE =>
'tags',
237 ParamValidator::PARAM_ISMULTI =>
true,
248 'action=tag&revid=123&add=vandalism&token=123ABC'
249 =>
'apihelp-tag-example-rev',
250 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
251 =>
'apihelp-tag-example-log',
256 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
This abstract class implements many basic API functions, and is the base of all API classes.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
requireAtLeastOneParameter( $params,... $required)
Die if 0 of a certain set of parameters is set and not false.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
dieBlocked(Block $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
This is the main API class, used for both external and internal processing.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
processIndividual( $type, $params, $id)
__construct(ApiMain $main, $action, IConnectionProvider $dbProvider, RevisionStore $revisionStore, ChangeTagsStore $changeTagsStore)
getExamplesMessages()
Returns usage examples for this module.
isWriteMode()
Indicates whether this module requires write mode.
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
mustBePosted()
Indicates whether this module must be called with a POST request.
needsToken()
Returns the token type this module requires in order to execute.
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.