52 parent::__construct( $main, $action );
65 $block = $user->getBlock();
66 if ( $block && $block->isSitewide() ) {
71 if ( $params[
'tags'] ) {
73 if ( !$ableToTag->isOK() ) {
81 if ( $params[
'revid'] ) {
82 foreach ( $params[
'revid'] as $id ) {
86 if ( $params[
'rcid'] ) {
87 foreach ( $params[
'rcid'] as $id ) {
91 if ( $params[
'logid'] ) {
92 foreach ( $params[
'logid'] as $id ) {
97 ApiResult::setIndexedTagName( $ret,
'result' );
102 $result = $this->dbr->selectField(
'logging',
'log_id', [
'log_id' => $logid ],
104 return (
bool)$result;
109 $idResult = [
$type => $id ];
115 $valid = RecentChange::newFromId( $id );
118 $idResult[
'status'] =
'error';
123 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
129 $valid = $this->revisionStore->getRevisionById( $id );
135 $idResult[
'status'] =
'error';
140 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
151 $idResult[
'status'] =
'error';
153 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
159 (
$type ===
'rcid' ? $id : null ),
160 (
$type ===
'revid' ? $id : null ),
161 (
$type ===
'logid' ? $id : null ),
167 if ( !$status->isOK() ) {
168 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
169 $idResult[
'status'] =
'skipped';
171 $idResult[
'status'] =
'failure';
172 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
175 $idResult[
'status'] =
'success';
176 if ( $status->value->logId ===
null ) {
177 $idResult[
'noop'] =
true;
179 $idResult[
'actionlogid'] = $status->value->logId;
180 $idResult[
'added'] = $status->value->addedTags;
181 ApiResult::setIndexedTagName( $idResult[
'added'],
't' );
182 $idResult[
'removed'] = $status->value->removedTags;
183 ApiResult::setIndexedTagName( $idResult[
'removed'],
't' );
185 if ( $params[
'tags'] ) {
239 'action=tag&revid=123&add=vandalism&token=123ABC'
240 =>
'apihelp-tag-example-rev',
241 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
242 =>
'apihelp-tag-example-log',
247 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 none 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.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
processIndividual( $type, $params, $id)
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.
__construct(ApiMain $main, $action, ILoadBalancer $loadBalancer, RevisionStore $revisionStore)
mustBePosted()
Indicates whether this module must be called with a POST request.
needsToken()
Returns the token type this module requires in order to execute.
RevisionStore $revisionStore