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 ) {
77 ApiResult::setIndexedTagName( $ret,
'result' );
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 ( $status->value->logId ===
null ) {
155 $idResult[
'noop'] =
true;
157 $idResult[
'actionlogid'] = $status->value->logId;
158 $idResult[
'added'] = $status->value->addedTags;
159 ApiResult::setIndexedTagName( $idResult[
'added'],
't' );
160 $idResult[
'removed'] = $status->value->removedTags;
161 ApiResult::setIndexedTagName( $idResult[
'removed'],
't' );
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.
getErrorFormatter()
Get the error formatter Stable to override.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
requireAtLeastOneParameter( $params,... $required)
Die if none of a certain set of parameters is set and not false.
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,...
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
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 Stable to override.
needsToken()
Returns the token type this module requires in order to execute.
getUser()
Stable to override.