135 $status = Status::newGood();
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 ) {
185 $itemStatus = Status::newGood();
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'] ?? [],
303 DeferredUpdates::addCallableUpdate(
304 function () use ( $visibilityChangeMap ) {
307 DeferredUpdates::PRESEND,
311 $dbw->endAtomic( __METHOD__ );