Go to the documentation of this file.
30 use ApiBlockInfoTrait;
36 $this->revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
45 $block = $user->getBlock();
46 if ( $block && $block->isSitewide() ) {
51 if ( $params[
'tags'] ) {
53 if ( !$ableToTag->isOK() ) {
61 if ( $params[
'revid'] ) {
62 foreach ( $params[
'revid'] as $id ) {
66 if ( $params[
'rcid'] ) {
67 foreach ( $params[
'rcid'] as $id ) {
71 if ( $params[
'logid'] ) {
72 foreach ( $params[
'logid'] as $id ) {
83 $result =
$dbr->selectField(
'logging',
'log_id', [
'log_id' => $logid ],
90 $idResult = [
$type => $id ];
98 $idResult[
'status'] =
'error';
103 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
109 $valid = $this->revisionStore->getRevisionById( $id );
114 $idResult[
'status'] =
'error';
119 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
130 $idResult[
'status'] =
'error';
132 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
138 (
$type ===
'rcid' ? $id :
null ),
139 (
$type ===
'revid' ? $id :
null ),
140 (
$type ===
'logid' ? $id :
null ),
146 if (
$status->hasMessage(
'actionthrottledtext' ) ) {
147 $idResult[
'status'] =
'skipped';
149 $idResult[
'status'] =
'failure';
153 $idResult[
'status'] =
'success';
154 if ( is_null(
$status->value->logId ) ) {
155 $idResult[
'noop'] =
true;
157 $idResult[
'actionlogid'] =
$status->value->logId;
158 $idResult[
'added'] =
$status->value->addedTags;
160 $idResult[
'removed'] =
$status->value->removedTags;
163 if ( $params[
'tags'] ) {
217 'action=tag&revid=123&add=vandalism&token=123ABC'
218 =>
'apihelp-tag-example-rev',
219 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
220 =>
'apihelp-tag-example-log',
225 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tag';
static validateLogId( $logid)
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
isWriteMode()
Indicates whether this module requires write mode.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
This abstract class implements many basic API functions, and is the base of all API classes.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
processIndividual( $type, $params, $id)
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
needsToken()
Returns the token type this module requires in order to execute.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
MediaWiki Revision RevisionStore $revisionStore
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
getExamplesMessages()
Returns usage examples for this module.
requireAtLeastOneParameter( $params, $required)
Die if none of a certain set of parameters is set and not false.
mustBePosted()
Indicates whether this module must be called with a POST request.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
getErrorFormatter()
Get the error formatter.
getHelpUrls()
Return links to more detailed help pages about the module.