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 ];
96 $valid = RecentChange::newFromId( $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 ),
145 if ( !$status->isOK() ) {
146 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
147 $idResult[
'status'] =
'skipped';
149 $idResult[
'status'] =
'failure';
150 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
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';
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
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.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getErrorFormatter()
Get the error formatter.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
requireAtLeastOneParameter( $params, $required)
Die if none of a certain set of parameters is set and not false.
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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)
static validateLogId( $logid)
MediaWiki Revision RevisionStore $revisionStore
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.