59 parent::__construct( $context,
$page );
63 $this->lbFactory = $lbFactory;
115 foreach ( $this as $item ) {
116 if ( $item->getBits() & self::SUPPRESS_BIT ) {
137 $status = Status::newGood();
139 $bitPars = $params[
'value'];
140 $comment = $params[
'comment'];
141 $perItemStatus = $params[
'perItemStatus'] ??
false;
145 $dbw = $this->lbFactory->getPrimaryDatabase();
146 $this->res = $this->
doQuery( $dbw );
149 if ( !$status->isGood() ) {
153 $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
154 $dbw->onTransactionResolution(
162 $missing = array_fill_keys( $this->ids,
true );
167 if ( $perItemStatus ) {
168 $status->value[
'itemStatuses'] = [];
180 $visibilityChangeMap = [];
183 foreach ( $this as $item ) {
184 unset( $missing[$item->getId()] );
186 if ( $perItemStatus ) {
187 $itemStatus = Status::newGood();
188 $status->value[
'itemStatuses'][$item->getId()] = $itemStatus;
190 $itemStatus = $status;
193 $oldBits = $item->getBits();
197 if ( $oldBits == $newBits ) {
198 $itemStatus->warning(
199 'revdelete-no-change', $item->formatDate(), $item->formatTime() );
200 $status->failCount++;
202 } elseif ( $oldBits == 0 && $newBits != 0 ) {
204 } elseif ( $oldBits != 0 && $newBits == 0 ) {
210 if ( $item->isHideCurrentOp( $newBits ) ) {
213 'revdelete-hide-current', $item->formatDate(), $item->formatTime() );
214 $status->failCount++;
216 } elseif ( !$item->canView() ) {
218 $msg = ( $opType ==
'show' ) ?
219 'revdelete-show-no-access' :
'revdelete-modify-no-access';
220 $itemStatus->error( $msg, $item->formatDate(), $item->formatTime() );
221 $status->failCount++;
224 } elseif ( $newBits == self::SUPPRESS_BIT ) {
225 $itemStatus->warning(
226 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() );
227 $status->failCount++;
232 $ok = $item->setBits( $newBits );
235 $idsForLog[] = $item->getId();
237 if ( ( $oldBits | $newBits ) & self::SUPPRESS_BIT ) {
238 $logType =
'suppress';
241 $addedBits = ( $oldBits ^ $newBits ) & $newBits;
242 $removedBits = ( $oldBits ^ $newBits ) & $oldBits;
243 $virtualNewBits |= $addedBits;
244 $virtualOldBits |= $removedBits;
246 $status->successCount++;
247 $authorActors[] = $item->getAuthorActor();
251 $visibilityChangeMap[$item->getId()] = [
252 'oldBits' => $oldBits,
253 'newBits' => $newBits,
257 'revdelete-concurrent-change', $item->formatDate(), $item->formatTime() );
258 $status->failCount++;
263 foreach ( $missing as $id => $unused ) {
264 if ( $perItemStatus ) {
265 $status->value[
'itemStatuses'][$id] = Status::newFatal(
'revdelete-modify-missing', $id );
267 $status->error(
'revdelete-modify-missing', $id );
269 $status->failCount++;
272 if ( $status->successCount == 0 ) {
273 $dbw->endAtomic( __METHOD__ );
278 $successCount = $status->successCount;
282 if ( !$status->isOK() ) {
284 $dbw->cancelAtomic( __METHOD__ );
290 $authorFields[
'authorActors'] = $authorActors;
294 'page' => $this->page,
295 'count' => $successCount,
296 'newBits' => $virtualNewBits,
297 'oldBits' => $virtualOldBits,
298 'comment' => $comment,
300 'tags' => $params[
'tags'] ?? [],
306 function () use ( $visibilityChangeMap ) {
309 DeferredUpdates::PRESEND,
313 $dbw->endAtomic( __METHOD__ );
319 $status = Status::newGood();
321 foreach ( $this as $item ) {
322 $status->merge( $item->lock() );
329 $status = Status::newGood();
331 foreach ( $this as $item ) {
332 $status->merge( $item->unlock() );
344 $dbw = $this->lbFactory->getPrimaryDatabase();
345 $this->res = $this->
doQuery( $dbw );
361 private function updateLog( $logType, $params ) {
365 throw new MWException(
"Bad log URL param type!" );
371 $logEntry->setTarget( $params[
'page'] );
372 $logEntry->setComment( $params[
'comment'] );
373 $logEntry->setParameters( $logParams );
374 $logEntry->setPerformer( $this->
getUser() );
377 $field => $params[
'ids'],
379 if ( isset( $params[
'authorActors'] ) ) {
381 'target_author_actor' => $params[
'authorActors'],
384 $logEntry->setRelations( $relations );
386 $logEntry->addTags( $params[
'tags'] );
387 $logId = $logEntry->insert();
388 $logEntry->publish( $logId );
407 '5::ids' => $params[
'ids'],
408 '6::ofield' => $params[
'oldBits'],
409 '7::nfield' => $params[
'newBits'],
426 return Status::newGood();
436 return Status::newGood();
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.
const SUPPRESS_BIT
Flag used for suppression, depending on the type of log.
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.
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.
Interface for objects which can provide a MediaWiki context on request.
Interface for objects (potentially) representing an editable wiki page.