41 private const ALLOWED_TYPES = [
43 'class' => RevDelRevisionList::class,
45 'DBLoadBalancerFactory',
52 'class' => RevDelArchiveList::class,
54 'DBLoadBalancerFactory',
61 'class' => RevDelFileList::class,
63 'DBLoadBalancerFactory',
69 'class' => RevDelArchivedFileList::class,
71 'DBLoadBalancerFactory',
77 'class' => RevDelLogList::class,
79 'DBLoadBalancerFactory',
81 'LogFormatterFactory',
87 private const DEPRECATED_TYPE_MAP = [
88 'oldid' =>
'revision',
89 'artimestamp' =>
'archive',
90 'oldimage' =>
'oldimage',
91 'fileid' =>
'filearchive',
102 return array_keys( self::ALLOWED_TYPES );
113 if ( isset( self::DEPRECATED_TYPE_MAP[$typeName] ) ) {
114 $typeName = self::DEPRECATED_TYPE_MAP[$typeName];
116 return isset( self::ALLOWED_TYPES[$typeName] ) ? $typeName :
null;
130 $typeName = self::getCanonicalTypeName( $typeName );
132 throw new InvalidArgumentException( __METHOD__ .
": Unknown RevDel type '$typeName'" );
134 $spec = self::ALLOWED_TYPES[$typeName];
135 $objectFactory = MediaWikiServices::getInstance()->getObjectFactory();
139 return $objectFactory->createObject(
142 'extraArgs' => [ $context, $page, $ids ],
143 'assertClass' => RevDelList::class,
159 protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
160 if ( $diff & $field ) {
161 $arr[( $new & $field ) ? 0 : 1][] = $desc;
185 $ret = [ 0 => [], 1 => [], 2 => [] ];
187 self::checkItem(
'revdelete-content',
188 RevisionRecord::DELETED_TEXT, $diff, $n, $ret );
189 self::checkItem(
'revdelete-summary',
190 RevisionRecord::DELETED_COMMENT, $diff, $n, $ret );
191 self::checkItem(
'revdelete-uname',
192 RevisionRecord::DELETED_USER, $diff, $n, $ret );
194 if ( $diff & RevisionRecord::DELETED_RESTRICTED ) {
195 if ( $n & RevisionRecord::DELETED_RESTRICTED ) {
196 $ret[2][] =
'revdelete-restricted';
198 $ret[2][] =
'revdelete-unrestricted';
211 $typeName = self::getCanonicalTypeName( $typeName );
215 return call_user_func( [ self::ALLOWED_TYPES[$typeName][
'class'],
'getRelationType' ] );
225 $typeName = self::getCanonicalTypeName( $typeName );
229 return call_user_func( [ self::ALLOWED_TYPES[$typeName][
'class'],
'getRestriction' ] );
239 $typeName = self::getCanonicalTypeName( $typeName );
243 return call_user_func( [ self::ALLOWED_TYPES[$typeName][
'class'],
'getRevdelConstant' ] );
255 $typeName = self::getCanonicalTypeName( $typeName );
259 return call_user_func(
260 [ self::ALLOWED_TYPES[$typeName][
'class'],
'suggestTarget' ],
276 foreach ( $bitPars as $const => $val ) {
279 } elseif ( $val == -1 ) {
280 $newBits |= ( $oldfield & $const );
General controller for RevDel, used by both SpecialRevisiondelete and ApiRevisionDelete.
static getCanonicalTypeName( $typeName)
Gets the canonical type name, if any.
static getTypes()
Lists the valid possible types for revision deletion.
static checkItem( $desc, $field, $diff, $new, &$arr)
Checks for a change in the bitfield for a certain option and updates the provided array accordingly.
static getRelationType( $typeName)
Get DB field name for URL param... Future code for other things may also track other types of revisio...
static getChanges( $n, $o)
Gets an array of message keys describing the changes made to the visibility of the revision.
static suggestTarget( $typeName, $target, array $ids)
Suggest a target for the revision deletion.
static extractBitfield(array $bitPars, $oldfield)
Put together a rev_deleted bitfield.
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.
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.