140 $status = Status::newGood();
144 $perItemStatus =
$params[
'perItemStatus'] ??
false;
148 $dbw = $this->lbFactory->getPrimaryDatabase();
149 $this->res = $this->
doQuery( $dbw );
152 if ( !$status->isGood() ) {
156 $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
157 $dbw->onTransactionResolution(
165 $missing = array_fill_keys( $this->ids,
true );
170 if ( $perItemStatus ) {
171 $status->value[
'itemStatuses'] = [];
183 $visibilityChangeMap = [];
186 foreach ( $this as $item ) {
187 unset( $missing[$item->getId()] );
189 if ( $perItemStatus ) {
190 $itemStatus = Status::newGood();
191 $status->value[
'itemStatuses'][$item->getId()] = $itemStatus;
193 $itemStatus = $status;
196 $oldBits = $item->getBits();
198 $newBits = RevisionDeleter::extractBitfield( $bitPars, $oldBits );
200 if ( $oldBits == $newBits ) {
201 $itemStatus->warning(
202 'revdelete-no-change', $item->formatDate(), $item->formatTime() );
203 $status->failCount++;
205 } elseif ( $oldBits == 0 && $newBits != 0 ) {
207 } elseif ( $oldBits != 0 && $newBits == 0 ) {
213 if ( $item->isHideCurrentOp( $newBits ) ) {
216 'revdelete-hide-current', $item->formatDate(), $item->formatTime() );
217 $status->failCount++;
219 } elseif ( !$item->canView() ) {
221 $msg = ( $opType ==
'show' ) ?
222 'revdelete-show-no-access' :
'revdelete-modify-no-access';
223 $itemStatus->error( $msg, $item->formatDate(), $item->formatTime() );
224 $status->failCount++;
227 } elseif ( $newBits == self::SUPPRESS_BIT ) {
228 $itemStatus->warning(
229 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() );
230 $status->failCount++;
235 $ok = $item->setBits( $newBits );
238 $idsForLog[] = $item->getId();
240 if ( ( $oldBits | $newBits ) & self::SUPPRESS_BIT ) {
241 $logType =
'suppress';
244 $addedBits = ( $oldBits ^ $newBits ) & $newBits;
245 $removedBits = ( $oldBits ^ $newBits ) & $oldBits;
246 $virtualNewBits |= $addedBits;
247 $virtualOldBits |= $removedBits;
249 $status->successCount++;
250 $authorActors[] = $item->getAuthorActor();
254 $visibilityChangeMap[$item->getId()] = [
255 'oldBits' => $oldBits,
256 'newBits' => $newBits,
260 'revdelete-concurrent-change', $item->formatDate(), $item->formatTime() );
261 $status->failCount++;
266 foreach ( $missing as $id => $unused ) {
267 if ( $perItemStatus ) {
268 $status->value[
'itemStatuses'][$id] = Status::newFatal(
'revdelete-modify-missing', $id );
270 $status->error(
'revdelete-modify-missing', $id );
272 $status->failCount++;
275 if ( $status->successCount == 0 ) {
276 $dbw->endAtomic( __METHOD__ );
281 $successCount = $status->successCount;
285 if ( !$status->isOK() ) {
287 $dbw->cancelAtomic( __METHOD__ );
293 $authorFields[
'authorActors'] = $authorActors;
297 'page' => $this->page,
298 'count' => $successCount,
299 'newBits' => $virtualNewBits,
300 'oldBits' => $virtualOldBits,
301 'comment' => $comment,
303 'tags' =>
$params[
'tags'] ?? [],
308 DeferredUpdates::addCallableUpdate(
309 function () use ( $visibilityChangeMap ) {
312 DeferredUpdates::PRESEND,
316 $dbw->endAtomic( __METHOD__ );