- $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-
- foreach ( $this->badItems as $row ) {
- list( $title, $namespace, $dbKey ) = $row;
- $action = $title ? 'cleaning up' : 'deleting';
- wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" );
-
- $store->removeWatch( $user, new TitleValue( (int)$namespace, $dbKey ) );
-
- // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
- if ( $title ) {
- $user->addWatch( $title );
+ $badItems = $this->badItems;
+ DeferredUpdates::addCallableUpdate( function () use ( $user, $badItems ) {
+ $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+ foreach ( $badItems as $row ) {
+ list( $title, $namespace, $dbKey ) = $row;
+ $action = $title ? 'cleaning up' : 'deleting';
+ wfDebug( "User {$user->getName()} has broken watchlist item " .
+ "ns($namespace):$dbKey, $action.\n" );
+
+ $store->removeWatch( $user, new TitleValue( (int)$namespace, $dbKey ) );
+ // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
+ if ( $title ) {
+ $user->addWatch( $title );
+ }