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();
195 $newBits = RevisionDeleter::extractBitfield( $bitPars, $oldBits );
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'] ?? [],
305 DeferredUpdates::addCallableUpdate(
306 function () use ( $visibilityChangeMap ) {
309 DeferredUpdates::PRESEND,
313 $dbw->endAtomic( __METHOD__ );