55 parent::__construct( $context,
$page );
59 $this->lbFactory = $lbFactory;
113 foreach ( $this as $item ) {
114 if ( $item->getBits() & $bit ) {
137 $bitPars = $params[
'value'];
138 $comment = $params[
'comment'];
139 $perItemStatus = $params[
'perItemStatus'] ??
false;
143 $dbw = $this->lbFactory->getPrimaryDatabase();
144 $this->res = $this->
doQuery( $dbw );
147 if ( !$status->isGood() ) {
151 $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
152 $dbw->onTransactionResolution(
160 $missing = array_fill_keys( $this->ids,
true );
165 if ( $perItemStatus ) {
166 $status->value[
'itemStatuses'] = [];
178 $visibilityChangeMap = [];
181 foreach ( $this as $item ) {
182 unset( $missing[$item->getId()] );
184 if ( $perItemStatus ) {
186 $status->value[
'itemStatuses'][$item->getId()] = $itemStatus;
188 $itemStatus = $status;
191 $oldBits = $item->getBits();
195 if ( $oldBits == $newBits ) {
196 $itemStatus->warning(
197 'revdelete-no-change', $item->formatDate(), $item->formatTime() );
198 $status->failCount++;
200 } elseif ( $oldBits == 0 && $newBits != 0 ) {
202 } elseif ( $oldBits != 0 && $newBits == 0 ) {
208 if ( $item->isHideCurrentOp( $newBits ) ) {
211 'revdelete-hide-current', $item->formatDate(), $item->formatTime() );
212 $status->failCount++;
214 } elseif ( !$item->canView() ) {
216 $msg = ( $opType ==
'show' ) ?
217 'revdelete-show-no-access' :
'revdelete-modify-no-access';
218 $itemStatus->error( $msg, $item->formatDate(), $item->formatTime() );
219 $status->failCount++;
222 } elseif ( $newBits == RevisionRecord::DELETED_RESTRICTED ) {
223 $itemStatus->warning(
224 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() );
225 $status->failCount++;
230 $ok = $item->setBits( $newBits );
233 $idsForLog[] = $item->getId();
236 $logType =
'suppress';
239 $addedBits = ( $oldBits ^ $newBits ) & $newBits;
240 $removedBits = ( $oldBits ^ $newBits ) & $oldBits;
241 $virtualNewBits |= $addedBits;
242 $virtualOldBits |= $removedBits;
244 $status->successCount++;
245 $authorActors[] = $item->getAuthorActor();
249 $visibilityChangeMap[$item->getId()] = [
250 'oldBits' => $oldBits,
251 'newBits' => $newBits,
255 'revdelete-concurrent-change', $item->formatDate(), $item->formatTime() );
256 $status->failCount++;
261 foreach ( $missing as $id => $unused ) {
262 if ( $perItemStatus ) {
263 $status->value[
'itemStatuses'][$id] =
Status::newFatal(
'revdelete-modify-missing', $id );
265 $status->error(
'revdelete-modify-missing', $id );
267 $status->failCount++;
270 if ( $status->successCount == 0 ) {
271 $dbw->endAtomic( __METHOD__ );
276 $successCount = $status->successCount;
280 if ( !$status->isOK() ) {
282 $dbw->cancelAtomic( __METHOD__ );
288 $authorFields[
'authorActors'] = $authorActors;
292 'page' => $this->page,
293 'count' => $successCount,
294 'newBits' => $virtualNewBits,
295 'oldBits' => $virtualOldBits,
296 'comment' => $comment,
298 'tags' => $params[
'tags'] ?? [],
304 function () use ( $visibilityChangeMap ) {
307 DeferredUpdates::PRESEND,
311 $dbw->endAtomic( __METHOD__ );
319 foreach ( $this as $item ) {
320 $status->merge( $item->lock() );
329 foreach ( $this as $item ) {
330 $status->merge( $item->unlock() );
342 $dbw = $this->lbFactory->getPrimaryDatabase();
343 $this->res = $this->
doQuery( $dbw );
359 private function updateLog( $logType, $params ) {
363 throw new MWException(
"Bad log URL param type!" );
369 $logEntry->setTarget( $params[
'page'] );
370 $logEntry->setComment( $params[
'comment'] );
371 $logEntry->setParameters( $logParams );
372 $logEntry->setPerformer( $this->
getUser() );
375 $field => $params[
'ids'],
377 if ( isset( $params[
'authorActors'] ) ) {
379 'target_author_actor' => $params[
'authorActors'],
382 $logEntry->setRelations( $relations );
384 $logEntry->addTags( $params[
'tags'] );
385 $logId = $logEntry->insert();
386 $logEntry->publish( $logId );
405 '5::ids' => $params[
'ids'],
406 '6::ofield' => $params[
'oldBits'],
407 '7::nfield' => $params[
'newBits'],
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add an update to the pending update queue that invokes the specified callback when run.
Class for creating new log entries and inserting them into the database.
setVisibility(array $params)
Set the visibility for the revisions in this list.
areAnySuppressed()
Indicate whether any item in this list is suppressed.
static suggestTarget( $target, array $ids)
Suggest a target for the revision deletion Optionally override this function.
doPreCommitUpdates()
A hook for setVisibility(): do batch updates pre-commit.
static getRestriction()
Get the user right required for this list type Override this function.
getLogAction()
Get the log action for this list type.
clearFileOps()
Clear any data structures needed for doPreCommitUpdates() and doPostCommitUpdates() STUB.
static getRelationType()
Get the DB field name associated with the ID list.
doPostCommitUpdates(array $visibilityChangeMap)
A hook for setVisibility(): do any necessary updates post-commit.
getSuppressBit()
Get the integer value of the flag used for suppression.
getLogParams( $params)
Get log parameter array.
static getRevdelConstant()
Get the revision deletion constant for this list type Override this function.
reloadFromPrimary()
Reload the list data from the primary DB.
__construct(IContextSource $context, PageIdentity $page, array $ids, LBFactory $lbFactory)
static getRelationType( $typeName)
Get DB field name for URL param...
static extractBitfield(array $bitPars, $oldfield)
Put together a rev_deleted bitfield.
List for revision table items for a single page.
getType()
Get the internal type name of this list.
doQuery( $db)
Do the DB query to iterate through the objects.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.