X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfixUserRegistration.php;h=e1b16829892431524dc2a27a802209201bbf32d3;hb=5490b1270a0a7447f28d2407736fc3c1deb41d44;hp=d09760b4bd115cd67a016bffdf4dfd6daec956d9;hpb=13e788862bc4349d732286970d57cd8375a7d774;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/fixUserRegistration.php b/maintenance/fixUserRegistration.php index d09760b4bd..e1b1682989 100644 --- a/maintenance/fixUserRegistration.php +++ b/maintenance/fixUserRegistration.php @@ -32,7 +32,7 @@ require_once __DIR__ . '/Maintenance.php'; class FixUserRegistration extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Fix the user_registration field"; + $this->addDescription( 'Fix the user_registration field' ); $this->setBatchSize( 1000 ); } @@ -45,32 +45,36 @@ class FixUserRegistration extends Maintenance { $res = $dbw->select( 'user', 'user_id', - array( + [ 'user_id > ' . $dbw->addQuotes( $lastId ), 'user_registration IS NULL' - ), + ], __METHOD__, - array( - 'LIMIT' => $this->mBatchSize, + [ + 'LIMIT' => $this->getBatchSize(), 'ORDER BY' => 'user_id', - ) + ] ); foreach ( $res as $row ) { $id = $row->user_id; $lastId = $id; // Get first edit time + $actorQuery = ActorMigration::newMigration() + ->getWhere( $dbw, 'rev_user', User::newFromId( $id ) ); $timestamp = $dbw->selectField( - 'revision', + [ 'revision' ] + $actorQuery['tables'], 'MIN(rev_timestamp)', - array( 'rev_user' => $id ), - __METHOD__ + $actorQuery['conds'], + __METHOD__, + [], + $actorQuery['joins'] ); // Update if ( $timestamp !== null ) { $dbw->update( 'user', - array( 'user_registration' => $timestamp ), - array( 'user_id' => $id ), + [ 'user_registration' => $timestamp ], + [ 'user_id' => $id ], __METHOD__ ); $user = User::newFromId( $id ); @@ -80,12 +84,12 @@ class FixUserRegistration extends Maintenance { $this->output( "Could not find registration for #$id NULL\n" ); } } - $this->output( "Waiting for slaves..." ); + $this->output( "Waiting for replica DBs..." ); wfWaitForSlaves(); $this->output( " done.\n" ); - } while ( $res->numRows() >= $this->mBatchSize ); + } while ( $res->numRows() >= $this->getBatchSize() ); } } -$maintClass = "FixUserRegistration"; +$maintClass = FixUserRegistration::class; require_once RUN_MAINTENANCE_IF_MAIN;