Merge "Log failure reasons in ApiLogin"
[lhc/web/wiklou.git] / maintenance / initEditCount.php
index dee5db8..50a4018 100644 (file)
@@ -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 );