42 if ( !$params[
'ids'] ) {
43 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
47 if ( $params[
'tags'] ) {
49 if ( !$ableToTag->isOK() ) {
54 $hide = $params[
'hide'] ?: [];
55 $show = $params[
'show'] ?: [];
56 if ( array_intersect( $hide, $show ) ) {
57 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
58 } elseif ( !$hide && !$show ) {
59 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
63 'comment' => RevisionRecord::DELETED_COMMENT,
64 'user' => RevisionRecord::DELETED_USER,
67 foreach ( $bits as $key => $bit ) {
68 if ( in_array( $key, $hide ) ) {
70 } elseif ( in_array( $key, $show ) ) {
77 if ( $params[
'suppress'] ===
'yes' ) {
79 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
80 } elseif ( $params[
'suppress'] ===
'no' ) {
81 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
83 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
87 if ( $params[
'target'] ) {
88 $targetObj = Title::newFromText( $params[
'target'] );
91 if ( $targetObj ===
null ) {
92 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
102 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
104 $status = $list->setVisibility( [
105 'value' => $bitfield,
106 'comment' => $params[
'reason'] ??
'',
107 'perItemStatus' =>
true,
108 'tags' => $params[
'tags']
112 $data = $this->extractStatusInfo( $status );
113 $data[
'target'] = $targetObj->getFullText();
116 foreach ( $status->
getValue()[
'itemStatuses'] as $id =>
$s ) {
117 $data[
'items'][$id] = $this->extractStatusInfo(
$s );
118 $data[
'items'][$id][
'id'] = $id;
121 $list->reloadFromPrimary();
122 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
123 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
126 $data[
'items'] = array_values( $data[
'items'] );
127 ApiResult::setIndexedTagName( $data[
'items'],
'i' );
131 private function extractStatusInfo(
Status $status ) {
133 'status' => $status->
isOK() ?
'Success' :
'Fail',
138 $ret[
'errors'] = $errors;
142 $ret[
'warnings'] = $warnings;
160 ParamValidator::PARAM_REQUIRED =>
true
164 ParamValidator::PARAM_ISMULTI =>
true,
165 ParamValidator::PARAM_REQUIRED =>
true
168 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
169 ParamValidator::PARAM_ISMULTI =>
true,
172 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
173 ParamValidator::PARAM_ISMULTI =>
true,
176 ParamValidator::PARAM_TYPE => [
'yes',
'no',
'nochange' ],
177 ParamValidator::PARAM_DEFAULT =>
'nochange',
180 ParamValidator::PARAM_TYPE =>
'string'
183 ParamValidator::PARAM_TYPE =>
'tags',
184 ParamValidator::PARAM_ISMULTI =>
true,
194 $title = Title::newMainPage()->getPrefixedText();
195 $mp = rawurlencode(
$title );
198 "action=revisiondelete&target={$mp}&type=revision&ids=12345&" .
199 'hide=content&token=123ABC'
200 =>
'apihelp-revisiondelete-example-revision',
201 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
202 'reason=BLP%20violation&token=123ABC'
203 =>
'apihelp-revisiondelete-example-log',
208 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.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s