34 if ( !$params[
'ids'] ) {
35 $this->
dieWithError( [
'apierror-paramempty',
'ids' ],
'paramempty_ids' );
39 if ( $params[
'tags'] ) {
40 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
41 if ( !$ableToTag->isOK() ) {
46 $hide = $params[
'hide'] ?: [];
47 $show = $params[
'show'] ?: [];
48 if ( array_intersect( $hide, $show ) ) {
49 $this->
dieWithError(
'apierror-revdel-mutuallyexclusive',
'badparams' );
50 } elseif ( !$hide && !$show ) {
51 $this->
dieWithError(
'apierror-revdel-paramneeded',
'badparams' );
55 'comment' => RevisionRecord::DELETED_COMMENT,
56 'user' => RevisionRecord::DELETED_USER,
59 foreach ( $bits as $key => $bit ) {
60 if ( in_array( $key, $hide ) ) {
62 } elseif ( in_array( $key, $show ) ) {
69 if ( $params[
'suppress'] ===
'yes' ) {
71 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 1;
72 } elseif ( $params[
'suppress'] ===
'no' ) {
73 $bitfield[RevisionRecord::DELETED_RESTRICTED] = 0;
75 $bitfield[RevisionRecord::DELETED_RESTRICTED] = -1;
79 if ( $params[
'target'] ) {
80 $targetObj = Title::newFromText( $params[
'target'] );
83 if ( $targetObj ===
null ) {
84 $this->
dieWithError( [
'apierror-revdel-needtarget' ],
'needtarget' );
94 $params[
'type'], $this->
getContext(), $targetObj, $params[
'ids']
96 $status = $list->setVisibility( [
98 'comment' => $params[
'reason'] ??
'',
99 'perItemStatus' =>
true,
100 'tags' => $params[
'tags']
104 $data = $this->extractStatusInfo( $status );
105 $data[
'target'] = $targetObj->getFullText();
108 foreach ( $status->
getValue()[
'itemStatuses'] as $id => $s ) {
109 $data[
'items'][$id] = $this->extractStatusInfo( $s );
110 $data[
'items'][$id][
'id'] = $id;
113 $list->reloadFromPrimary();
114 foreach ( $list as $item ) {
115 $data[
'items'][$item->getId()] += $item->getApiData( $this->
getResult() );
118 $data[
'items'] = array_values( $data[
'items'] );
123 private function extractStatusInfo(
Status $status ): array {
125 'status' => $status->isOK() ?
'Success' :
'Fail',
130 $ret[
'errors'] = $errors;
134 $ret[
'warnings'] = $warnings;
155 ParamValidator::PARAM_REQUIRED => true
159 ParamValidator::PARAM_ISMULTI =>
true,
160 ParamValidator::PARAM_REQUIRED => true
163 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
164 ParamValidator::PARAM_ISMULTI =>
true,
167 ParamValidator::PARAM_TYPE => [
'content',
'comment',
'user' ],
168 ParamValidator::PARAM_ISMULTI =>
true,
171 ParamValidator::PARAM_TYPE => [
'yes',
'no',
'nochange' ],
172 ParamValidator::PARAM_DEFAULT =>
'nochange',
175 ParamValidator::PARAM_TYPE =>
'string'
178 ParamValidator::PARAM_TYPE =>
'tags',
179 ParamValidator::PARAM_ISMULTI =>
true,
191 $title = Title::newMainPage()->getPrefixedText();
192 $mp = rawurlencode( $title );
195 "action=revisiondelete&target={$mp}&type=revision&ids=12345&" .
196 'hide=content&token=123ABC'
197 =>
'apihelp-revisiondelete-example-revision',
198 'action=revisiondelete&type=logging&ids=67890&hide=content|comment|user&' .
199 'reason=BLP%20violation&token=123ABC'
200 =>
'apihelp-revisiondelete-example-log',
206 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Revisiondelete';
211class_alias( ApiRevisionDelete::class,
'ApiRevisionDelete' );