X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FremoveUnusedAccounts.php;h=6b2f4886c6e90a47a9f445d0b50c7d6dff03cd84;hb=1658759d42a5d802e29a71c3fd70ae127afd3e46;hp=e066300c58ba203706068405a18bc1fd30182713;hpb=77e3624caba072521fbc1826af2d47f9b29f4032;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index e066300c58..6b2f4886c6 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -48,7 +48,7 @@ class RemoveUnusedAccounts extends Maintenance { $delUser = []; $delActor = []; $dbr = $this->getDB( DB_REPLICA ); - if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { $res = $dbr->select( [ 'user', 'actor' ], [ 'user_id', 'user_name', 'user_touched', 'actor_id' ], @@ -75,12 +75,12 @@ class RemoveUnusedAccounts extends Maintenance { # group or if it's touched within the $touchedSeconds seconds. $instance = User::newFromId( $row->user_id ); if ( count( array_intersect( $instance->getEffectiveGroups(), $excludedGroups ) ) == 0 - && $this->isInactiveAccount( $row->user_id, $row->actor_id, true ) + && $this->isInactiveAccount( $row->user_id, $row->actor_id ?? null, true ) && wfTimestamp( TS_UNIX, $row->user_touched ) < wfTimestamp( TS_UNIX, time() - $touchedSeconds ) ) { # Inactive; print out the name and flag it $delUser[] = $row->user_id; - if ( $row->actor_id ) { + if ( isset( $row->actor_id ) && $row->actor_id ) { $delActor[] = $row->actor_id; } $this->output( $row->user_name . "\n" ); @@ -94,7 +94,7 @@ class RemoveUnusedAccounts extends Maintenance { $this->output( "\nDeleting unused accounts..." ); $dbw = $this->getDB( DB_MASTER ); $dbw->delete( 'user', [ 'user_id' => $delUser ], __METHOD__ ); - if ( $wgActorTableSchemaMigrationStage > MIGRATION_OLD ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { # Keep actor rows referenced from ipblocks $keep = $dbw->selectFieldValues( 'ipblocks', 'ipb_by_actor', [ 'ipb_by_actor' => $delActor ], __METHOD__ @@ -110,11 +110,11 @@ class RemoveUnusedAccounts extends Maintenance { $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 ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_NEW ) { $dbw->delete( 'logging', [ 'log_actor' => $delActor ], __METHOD__ ); $dbw->delete( 'recentchanges', [ 'rc_actor' => $delActor ], __METHOD__ ); } - if ( $wgActorTableSchemaMigrationStage < MIGRATION_NEW ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_WRITE_OLD ) { $dbw->delete( 'logging', [ 'log_user' => $delUser ], __METHOD__ ); $dbw->delete( 'recentchanges', [ 'rc_user' => $delUser ], __METHOD__ ); } @@ -138,7 +138,7 @@ class RemoveUnusedAccounts extends Maintenance { * (No edits, no deleted edits, no log entries, no current/old uploads) * * @param int $id User's ID - * @param int $actor User's actor ID + * @param int|null $actor User's actor ID * @param bool $master Perform checking on the master * @return bool */