- $dbw->delete( 'user', [ 'user_id' => $del ], __METHOD__ );
- $dbw->delete( 'user_groups', [ 'ug_user' => $del ], __METHOD__ );
- $dbw->delete( 'user_former_groups', [ 'ufg_user' => $del ], __METHOD__ );
- $dbw->delete( 'user_properties', [ 'up_user' => $del ], __METHOD__ );
- $dbw->delete( 'logging', [ 'log_user' => $del ], __METHOD__ );
- $dbw->delete( 'recentchanges', [ 'rc_user' => $del ], __METHOD__ );
+ $dbw->delete( 'user', [ 'user_id' => $delUser ], __METHOD__ );
+ if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
+ # Keep actor rows referenced from ipblocks
+ $keep = $dbw->selectFieldValues(
+ 'ipblocks', 'ipb_by_actor', [ 'ipb_by_actor' => $delActor ], __METHOD__
+ );
+ $del = array_diff( $delActor, $keep );
+ if ( $del ) {
+ $dbw->delete( 'actor', [ 'actor_id' => $del ], __METHOD__ );
+ }
+ if ( $keep ) {
+ $dbw->update( 'actor', [ 'actor_user' => 0 ], [ 'actor_id' => $keep ], __METHOD__ );
+ }
+ }
+ $dbw->delete( 'user_groups', [ 'ug_user' => $delUser ], __METHOD__ );
+ $dbw->delete( 'user_former_groups', [ 'ufg_user' => $delUser ], __METHOD__ );
+ $dbw->delete( 'user_properties', [ 'up_user' => $delUser ], __METHOD__ );
+ if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) {
+ $dbw->delete( 'logging', [ 'log_actor' => $delActor ], __METHOD__ );
+ $dbw->delete( 'recentchanges', [ 'rc_actor' => $delActor ], __METHOD__ );
+ }
+ if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) {
+ $dbw->delete( 'logging', [ 'log_user' => $delUser ], __METHOD__ );
+ $dbw->delete( 'recentchanges', [ 'rc_user' => $delUser ], __METHOD__ );
+ }