39 private $revisionStore;
53 parent::__construct( $main, $action );
55 $this->revisionStore = $revisionStore;
66 $block = $user->getBlock();
67 if ( $block && $block->isSitewide() ) {
72 if ( $params[
'tags'] ) {
74 if ( !$ableToTag->isOK() ) {
82 if ( $params[
'revid'] ) {
83 foreach ( $params[
'revid'] as $id ) {
87 if ( $params[
'rcid'] ) {
88 foreach ( $params[
'rcid'] as $id ) {
92 if ( $params[
'logid'] ) {
93 foreach ( $params[
'logid'] as $id ) {
98 ApiResult::setIndexedTagName( $ret,
'result' );
103 $result = $this->dbr->selectField(
'logging',
'log_id', [
'log_id' => $logid ],
105 return (
bool)$result;
110 $idResult = [
$type => $id ];
116 $valid = RecentChange::newFromId( $id );
119 $idResult[
'status'] =
'error';
125 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
131 $valid = $this->revisionStore->getRevisionById( $id );
137 $idResult[
'status'] =
'error';
143 [
'blockinfo' => $this->getBlockDetails( $user->getBlock() ) ]
154 $idResult[
'status'] =
'error';
156 $idResult += $this->
getErrorFormatter()->formatMessage( [
"apierror-nosuch$type", $id ] );
162 (
$type ===
'rcid' ? $id : null ),
163 (
$type ===
'revid' ? $id : null ),
164 (
$type ===
'logid' ? $id : null ),
170 if ( !$status->isOK() ) {
171 if ( $status->hasMessage(
'actionthrottledtext' ) ) {
172 $idResult[
'status'] =
'skipped';
174 $idResult[
'status'] =
'failure';
175 $idResult[
'errors'] = $this->
getErrorFormatter()->arrayFromStatus( $status,
'error' );
178 $idResult[
'status'] =
'success';
179 if ( $status->value->logId ===
null ) {
180 $idResult[
'noop'] =
true;
182 $idResult[
'actionlogid'] = $status->value->logId;
183 $idResult[
'added'] = $status->value->addedTags;
184 ApiResult::setIndexedTagName( $idResult[
'added'],
't' );
185 $idResult[
'removed'] = $status->value->removedTags;
186 ApiResult::setIndexedTagName( $idResult[
'removed'],
't' );
188 if ( $params[
'tags'] ) {
207 ParamValidator::PARAM_TYPE =>
'integer',
208 ParamValidator::PARAM_ISMULTI =>
true,
211 ParamValidator::PARAM_TYPE =>
'integer',
212 ParamValidator::PARAM_ISMULTI =>
true,
215 ParamValidator::PARAM_TYPE =>
'integer',
216 ParamValidator::PARAM_ISMULTI =>
true,
219 ParamValidator::PARAM_TYPE =>
'tags',
220 ParamValidator::PARAM_ISMULTI =>
true,
223 ParamValidator::PARAM_TYPE =>
'string',
224 ParamValidator::PARAM_ISMULTI =>
true,
227 ParamValidator::PARAM_TYPE =>
'string',
228 ParamValidator::PARAM_DEFAULT =>
'',
231 ParamValidator::PARAM_TYPE =>
'tags',
232 ParamValidator::PARAM_ISMULTI =>
true,
243 'action=tag&revid=123&add=vandalism&token=123ABC'
244 =>
'apihelp-tag-example-rev',
245 'action=tag&logid=123&remove=spam&reason=Wrongly+applied&token=123ABC'
246 =>
'apihelp-tag-example-log',
251 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.