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' );
99 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
101 $status = $list->setVisibility( [
102 'value' => $bitfield,
103 'comment' => $params[
'reason'],
104 'perItemStatus' =>
true,
105 'tags' => $params[
'tags']
110 $data[
'target'] = $targetObj->getFullText();
113 foreach ( $status->itemStatuses as $id =>
$s ) {
115 $data[
'items'][$id][
'id'] = $id;
118 $list->reloadFromMaster();
119 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
120 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
123 $data[
'items'] = array_values( $data[
'items'] );
124 ApiResult::setIndexedTagName( $data[
'items'],
'i' );
130 'status' => $status->isOK() ?
'Success' :
'Fail',
135 $ret[
'errors'] = $errors;
139 $ret[
'warnings'] = $warnings;
190 'action=revisiondelete&target=Main%20Page&type=revision&ids=12345&' .
191 'hide=content&token=123ABC'
192 =>
'apihelp-revisiondelete-example-revision',
193 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
194 'reason=BLP%20violation&token=123ABC'
195 =>
'apihelp-revisiondelete-example-log',
200 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.
const PARAM_REQUIRED
(boolean) Is the parameter required?
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getErrorFormatter()
Get the error formatter.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
dieBlocked(AbstractBlock $block)
Throw an ApiUsageException, which will (if uncaught) call the main module's error handler and die wit...
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.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
extractStatusInfo( $status)
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 createList( $typeName, IContextSource $context, Title $title, array $ids)
Instantiate the appropriate list class for a given list of IDs.
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.