43 if ( !$params[
'ids'] ) {
44 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
48 if ( $params[
'tags'] ) {
50 if ( !$ableToTag->isOK() ) {
55 $hide = $params[
'hide'] ?: [];
56 $show = $params[
'show'] ?: [];
57 if ( array_intersect( $hide, $show ) ) {
58 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
59 } elseif ( !$hide && !$show ) {
60 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
64 'comment' => RevisionRecord::DELETED_COMMENT,
65 'user' => RevisionRecord::DELETED_USER,
68 foreach ( $bits as $key => $bit ) {
69 if ( in_array( $key, $hide ) ) {
71 } elseif ( in_array( $key, $show ) ) {
78 if ( $params[
'suppress'] ===
'yes' ) {
80 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
81 } elseif ( $params[
'suppress'] ===
'no' ) {
82 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
84 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
88 if ( $params[
'target'] ) {
89 $targetObj = Title::newFromText( $params[
'target'] );
92 if ( $targetObj ===
null ) {
93 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
103 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
105 $status = $list->setVisibility( [
106 'value' => $bitfield,
107 'comment' => $params[
'reason'] ??
'',
108 'perItemStatus' =>
true,
109 'tags' => $params[
'tags']
113 $data = $this->extractStatusInfo( $status );
114 $data[
'target'] = $targetObj->getFullText();
117 foreach ( $status->
getValue()[
'itemStatuses'] as $id => $s ) {
118 $data[
'items'][$id] = $this->extractStatusInfo( $s );
119 $data[
'items'][$id][
'id'] = $id;
122 $list->reloadFromPrimary();
123 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
124 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
127 $data[
'items'] = array_values( $data[
'items'] );
128 ApiResult::setIndexedTagName( $data[
'items'],
'i' );
132 private function extractStatusInfo(
Status $status ) {
134 'status' => $status->
isOK() ?
'Success' :
'Fail',
139 $ret[
'errors'] = $errors;
143 $ret[
'warnings'] = $warnings;
161 ParamValidator::PARAM_REQUIRED =>
true
165 ParamValidator::PARAM_ISMULTI =>
true,
166 ParamValidator::PARAM_REQUIRED =>
true
169 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
170 ParamValidator::PARAM_ISMULTI =>
true,
173 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
174 ParamValidator::PARAM_ISMULTI =>
true,
177 ParamValidator::PARAM_TYPE => [
'yes',
'no',
'nochange' ],
178 ParamValidator::PARAM_DEFAULT =>
'nochange',
181 ParamValidator::PARAM_TYPE =>
'string'
184 ParamValidator::PARAM_TYPE =>
'tags',
185 ParamValidator::PARAM_ISMULTI =>
true,
195 $title = Title::newMainPage()->getPrefixedText();
196 $mp = rawurlencode(
$title );
199 "action=revisiondelete&target={$mp}&type=revision&ids=12345&" .
200 'hide=content&token=123ABC'
201 =>
'apihelp-revisiondelete-example-revision',
202 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
203 'reason=BLP%20violation&token=123ABC'
204 =>
'apihelp-revisiondelete-example-log',
209 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Revisiondelete';
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
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.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
dieBlocked(Block $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
isWriteMode()
Indicates whether this module requires write mode.
mustBePosted()
Indicates whether this module must be called with a POST request.
getExamplesMessages()
Returns usage examples for this module.
getHelpUrls()
Return links to more detailed help pages about the module.
needsToken()
Returns the token type this module requires in order to execute.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getContext()
Get the base IContextSource object.
static getTypes()
Lists the valid possible types for revision deletion.
static suggestTarget( $typeName, $target, array $ids)
Suggest a target for the revision deletion.
static getRevdelConstant( $typeName)
Get the revision deletion constant for the RevDel type.
static getRestriction( $typeName)
Get the user right required for the RevDel type.
static createList( $typeName, IContextSource $context, PageIdentity $page, array $ids)
Instantiate the appropriate list class for a given list of IDs.
isOK()
Returns whether the operation completed.
Generic operation result class Has warning/error list, boolean status and arbitrary value.