X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FremoveInvalidEmails.php;h=ec68ef2e77874ddb71455d5fa79ad63bbed62ae9;hb=2323b0ba8161892714c3aba9fc6a4212397e0283;hp=7ff69a1fecbef614742e333ffc51eebdf7108726;hpb=4770a3a93d1b95dc481af93e1fdc3f49c87dd66f;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/removeInvalidEmails.php b/maintenance/removeInvalidEmails.php index 7ff69a1fec..ec68ef2e77 100644 --- a/maintenance/removeInvalidEmails.php +++ b/maintenance/removeInvalidEmails.php @@ -23,30 +23,30 @@ class RemoveInvalidEmails extends Maintenance { } public function execute() { $this->commit = $this->hasOption( 'commit' ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); $lastId = 0; do { $rows = $dbr->select( 'user', - array( 'user_id', 'user_email' ), - array( + [ 'user_id', 'user_email' ], + [ 'user_id > ' . $dbr->addQuotes( $lastId ), 'user_email != ""', 'user_email_authenticated IS NULL' - ), + ], __METHOD__, - array( 'LIMIT' => $this->mBatchSize ) + [ 'LIMIT' => $this->getBatchSize() ] ); $count = $rows->numRows(); - $badIds = array(); + $badIds = []; foreach ( $rows as $row ) { if ( !Sanitizer::validateEmail( trim( $row->user_email ) ) ) { $this->output( "Found bad email: {$row->user_email} for user #{$row->user_id}\n" ); $badIds[] = $row->user_id; - if ( $row->user_id > $lastId ) { - $lastId = $row->user_id; - } + } + if ( $row->user_id > $lastId ) { + $lastId = $row->user_id; } } @@ -56,8 +56,8 @@ class RemoveInvalidEmails extends Maintenance { $this->output( "Removing $badCount emails from the database.\n" ); $dbw->update( 'user', - array( 'user_email' => '' ), - array( 'user_id' => $badIds ), + [ 'user_email' => '' ], + [ 'user_id' => $badIds ], __METHOD__ ); foreach ( $badIds as $badId ) { @@ -74,5 +74,5 @@ class RemoveInvalidEmails extends Maintenance { } } -$maintClass = 'RemoveInvalidEmails'; +$maintClass = RemoveInvalidEmails::class; require_once RUN_MAINTENANCE_IF_MAIN;