44 if ( !$params[
'ids'] ) {
45 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
49 if ( $params[
'tags'] ) {
51 if ( !$ableToTag->isOK() ) {
56 $hide = $params[
'hide'] ?: [];
57 $show = $params[
'show'] ?: [];
58 if ( array_intersect( $hide, $show ) ) {
59 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
60 } elseif ( !$hide && !$show ) {
61 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
65 'comment' => RevisionRecord::DELETED_COMMENT,
66 'user' => RevisionRecord::DELETED_USER,
69 foreach ( $bits as $key => $bit ) {
70 if ( in_array( $key, $hide ) ) {
72 } elseif ( in_array( $key, $show ) ) {
79 if ( $params[
'suppress'] ===
'yes' ) {
81 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
82 } elseif ( $params[
'suppress'] ===
'no' ) {
83 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
85 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
89 if ( $params[
'target'] ) {
90 $targetObj = Title::newFromText( $params[
'target'] );
93 if ( $targetObj ===
null ) {
94 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
104 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
106 $status = $list->setVisibility( [
107 'value' => $bitfield,
108 'comment' => $params[
'reason'] ??
'',
109 'perItemStatus' =>
true,
110 'tags' => $params[
'tags']
114 $data = $this->extractStatusInfo( $status );
115 $data[
'target'] = $targetObj->getFullText();
118 foreach ( $status->
getValue()[
'itemStatuses'] as $id => $s ) {
119 $data[
'items'][$id] = $this->extractStatusInfo( $s );
120 $data[
'items'][$id][
'id'] = $id;
123 $list->reloadFromPrimary();
124 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
125 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
128 $data[
'items'] = array_values( $data[
'items'] );
133 private function extractStatusInfo(
Status $status ) {
135 'status' => $status->
isOK() ?
'Success' :
'Fail',
140 $ret[
'errors'] = $errors;
144 $ret[
'warnings'] = $warnings;
162 ParamValidator::PARAM_REQUIRED =>
true
166 ParamValidator::PARAM_ISMULTI =>
true,
167 ParamValidator::PARAM_REQUIRED =>
true
170 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
171 ParamValidator::PARAM_ISMULTI =>
true,
174 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
175 ParamValidator::PARAM_ISMULTI =>
true,
178 ParamValidator::PARAM_TYPE => [
'yes',
'no',
'nochange' ],
179 ParamValidator::PARAM_DEFAULT =>
'nochange',
182 ParamValidator::PARAM_TYPE =>
'string'
185 ParamValidator::PARAM_TYPE =>
'tags',
186 ParamValidator::PARAM_ISMULTI =>
true,
196 $title = Title::newMainPage()->getPrefixedText();
197 $mp = rawurlencode( $title );
200 "action=revisiondelete&target={$mp}&type=revision&ids=12345&" .
201 'hide=content&token=123ABC'
202 =>
'apihelp-revisiondelete-example-revision',
203 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
204 'reason=BLP%20violation&token=123ABC'
205 =>
'apihelp-revisiondelete-example-log',
210 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...
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
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.