49 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
55 if ( !$ableToTag->isOK() ) {
62 if ( array_intersect( $hide, $show ) ) {
63 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
64 } elseif ( !$hide && !$show ) {
65 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
69 'comment' => RevisionRecord::DELETED_COMMENT,
70 'user' => RevisionRecord::DELETED_USER,
73 foreach ( $bits as $key => $bit ) {
74 if ( in_array( $key, $hide ) ) {
76 } elseif ( in_array( $key, $show ) ) {
83 if (
$params[
'suppress'] ===
'yes' ) {
85 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
86 } elseif (
$params[
'suppress'] ===
'no' ) {
87 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
89 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
94 $targetObj = Title::newFromText(
$params[
'target'] );
97 if ( $targetObj ===
null ) {
98 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
110 $status = $list->setVisibility( [
111 'value' => $bitfield,
112 'comment' =>
$params[
'reason'] ??
'',
113 'perItemStatus' =>
true,
118 $data = $this->extractStatusInfo( $status );
119 $data[
'target'] = $targetObj->getFullText();
122 foreach ( $status->
getValue()[
'itemStatuses'] as $id => $s ) {
123 $data[
'items'][$id] = $this->extractStatusInfo( $s );
124 $data[
'items'][$id][
'id'] = $id;
127 $list->reloadFromPrimary();
128 for ( $item = $list->reset(); $list->current(); $item = $list->next() ) {
129 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
132 $data[
'items'] = array_values( $data[
'items'] );
137 private function extractStatusInfo(
Status $status ) {
139 'status' => $status->
isOK() ?
'Success' :
'Fail',
144 $ret[
'errors'] = $errors;
148 $ret[
'warnings'] = $warnings;
166 ParamValidator::PARAM_REQUIRED => true
170 ParamValidator::PARAM_ISMULTI =>
true,
171 ParamValidator::PARAM_REQUIRED => true
174 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
175 ParamValidator::PARAM_ISMULTI =>
true,
178 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
179 ParamValidator::PARAM_ISMULTI =>
true,
182 ParamValidator::PARAM_TYPE => [
'yes',
'no',
'nochange' ],
183 ParamValidator::PARAM_DEFAULT =>
'nochange',
186 ParamValidator::PARAM_TYPE =>
'string'
189 ParamValidator::PARAM_TYPE =>
'tags',
190 ParamValidator::PARAM_ISMULTI =>
true,
200 $title = Title::newMainPage()->getPrefixedText();
201 $mp = rawurlencode( $title );
204 "action=revisiondelete&target={$mp}&type=revision&ids=12345&" .
205 'hide=content&token=123ABC'
206 =>
'apihelp-revisiondelete-example-revision',
207 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
208 'reason=BLP%20violation&token=123ABC'
209 =>
'apihelp-revisiondelete-example-log',
214 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Revisiondelete';
219class_alias( ApiRevisionDelete::class,
'ApiRevisionDelete' );
array $params
The job parameters.
General controller for RevDel, used by both SpecialRevisiondelete and ApiRevisionDelete.
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.