41 if ( !$params[
'ids'] ) {
42 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
46 if ( $params[
'tags'] ) {
48 if ( !$ableToTag->isOK() ) {
53 $hide = $params[
'hide'] ?: [];
54 $show = $params[
'show'] ?: [];
55 if ( array_intersect( $hide, $show ) ) {
56 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
57 } elseif ( !$hide && !$show ) {
58 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
62 'comment' => RevisionRecord::DELETED_COMMENT,
63 'user' => RevisionRecord::DELETED_USER,
66 foreach ( $bits as $key => $bit ) {
67 if ( in_array( $key, $hide ) ) {
69 } elseif ( in_array( $key, $show ) ) {
76 if ( $params[
'suppress'] ===
'yes' ) {
78 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
79 } elseif ( $params[
'suppress'] ===
'no' ) {
80 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
82 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
86 if ( $params[
'target'] ) {
87 $targetObj = Title::newFromText( $params[
'target'] );
90 if ( $targetObj ===
null ) {
91 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
100 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
102 $status = $list->setVisibility( [
103 'value' => $bitfield,
104 'comment' => $params[
'reason'],
105 'perItemStatus' =>
true,
106 'tags' => $params[
'tags']
111 $data[
'target'] = $targetObj->getFullText();
114 foreach ( $status->itemStatuses as $id =>
$s ) {
116 $data[
'items'][$id][
'id'] = $id;
119 $list->reloadFromPrimary();
120 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
121 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
124 $data[
'items'] = array_values( $data[
'items'] );
125 ApiResult::setIndexedTagName( $data[
'items'],
'i' );
131 'status' => $status->
isOK() ?
'Success' :
'Fail',
136 $ret[
'errors'] = $errors;
140 $ret[
'warnings'] = $warnings;
191 'action=revisiondelete&target=Main%20Page&type=revision&ids=12345&' .
192 'hide=content&token=123ABC'
193 =>
'apihelp-revisiondelete-example-revision',
194 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
195 'reason=BLP%20violation&token=123ABC'
196 =>
'apihelp-revisiondelete-example-log',
201 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.
extractStatusInfo(Status $status)
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