fetchUsersWithNotificationsForEvents( $eventIds ); $eventMapper->toggleDeleted( $eventIds, $moderate ); DeferredUpdates::addCallableUpdate( function () use ( $affectedUserIds ) { // This update runs after the main transaction round commits. // Wait for the event deletions to be propagated to replica DBs $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $lbFactory->waitForReplication( [ 'timeout' => 5 ] ); $lbFactory->flushReplicaSnapshots( 'EchoModerationController::moderate' ); // Recompute the notification count for the // users whose notifications have been moderated. foreach ( $affectedUserIds as $userId ) { $user = User::newFromId( $userId ); MWEchoNotifUser::newFromUser( $user )->resetNotificationCount( DB_REPLICA ); } } ); } }