X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FinitEditCount.php;h=50a40180a522bdf8f1d4c9e238c0341f821e3cb8;hb=2686727565a3eb1a9afff53b7c8b0d6b1106fb50;hp=dee5db8aef56ebbad5875f0953f37079ccb96d9b;hpb=174f34a86de3162bc673fd3bc6bed815cccf0edc;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index dee5db8aef..50a40180a5 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -32,10 +32,9 @@ class InitEditCount extends Maintenance { avoids locking tables or lagging slaves with large updates; calculates counts on a slave if possible. -Background mode will be automatically used if the server is MySQL 4.0 -(which does not support subqueries) or if multiple servers are listed +Background mode will be automatically used if multiple servers are listed in the load balancer, usually indicating a replication environment.' ); - $this->mDescription = "Batch-recalculate user_editcount fields from the revision table"; + $this->addDescription( 'Batch-recalculate user_editcount fields from the revision table' ); } public function execute() { @@ -46,13 +45,12 @@ in the load balancer, usually indicating a replication environment.' ); $dbver = $dbw->getServerVersion(); // Autodetect mode... - $backgroundMode = wfGetLB()->getServerCount() > 1 || - ( $dbw instanceof DatabaseMysql ); - if ( $this->hasOption( 'background' ) ) { $backgroundMode = true; } elseif ( $this->hasOption( 'quick' ) ) { $backgroundMode = false; + } else { + $backgroundMode = wfGetLB()->getServerCount() > 1; } if ( $backgroundMode ) { @@ -78,8 +76,8 @@ in the load balancer, usually indicating a replication environment.' ); foreach ( $result as $row ) { $dbw->update( 'user', - array( 'user_editcount' => $row->user_editcount ), - array( 'user_id' => $row->user_id ), + [ 'user_editcount' => $row->user_editcount ], + [ 'user_id' => $row->user_id ], __METHOD__ ); ++$migrated; } @@ -96,7 +94,6 @@ in the load balancer, usually indicating a replication environment.' ); wfWaitForSlaves(); } } else { - // Subselect should work on modern MySQLs etc $this->output( "Using single-query mode...\n" ); $sql = "UPDATE $user SET user_editcount=(SELECT COUNT(*) FROM $revision WHERE rev_user=user_id)"; $dbw->query( $sql );