X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fdeferred%2FUserEditCountUpdate.php;h=687dfbe907385027218d50734c6229739f26db23;hb=a6a6c19c794619c24881d2d984dc18ceb3b6419b;hp=e9ebabb643692ca60d4971b0aa195ee80a6a99e9;hpb=2e0cf0891444367942677692cf8efde87f19c3ef;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/deferred/UserEditCountUpdate.php b/includes/deferred/UserEditCountUpdate.php index e9ebabb643..687dfbe907 100644 --- a/includes/deferred/UserEditCountUpdate.php +++ b/includes/deferred/UserEditCountUpdate.php @@ -67,7 +67,7 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { */ public function doUpdate() { $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); - $dbw = $lb->getConnection( DB_MASTER ); + $dbw = $lb->getConnectionRef( DB_MASTER ); $fname = __METHOD__; ( new AutoCommitUpdate( $dbw, __METHOD__, function () use ( $lb, $dbw, $fname ) { @@ -82,20 +82,19 @@ class UserEditCountUpdate implements DeferrableUpdate, MergeableUpdate { $affectedInstances = $info['instances']; // Lazy initialization check... if ( $dbw->affectedRows() == 0 ) { - // No rows will be "affected" if user_editcount is NULL. - // Check if the generic "replica" connection is not the master. - $dbr = $lb->getConnection( DB_REPLICA ); - if ( $dbr !== $dbw ) { - // This method runs after the new revisions were committed. - // Wait for the replica to catch up so they will all be counted. - $dbr->flushSnapshot( $fname ); - $lb->waitForMasterPos( $dbr ); - } - $affectedInstances[0]->initEditCountInternal(); + // The user_editcount is probably NULL (e.g. not initialized). + // Since this update runs after the new revisions were committed, + // wait for the replica DB to catch up so they will be counted. + $dbr = $lb->getConnectionRef( DB_REPLICA ); + // If $dbr is actually the master DB, then clearing the snapshot + // is harmless and waitForMasterPos() will just no-op. + $dbr->flushSnapshot( $fname ); + $lb->waitForMasterPos( $dbr ); + $affectedInstances[0]->initEditCountInternal( $dbr ); } $newCount = (int)$dbw->selectField( 'user', - [ 'user_editcount' ], + 'user_editcount', [ 'user_id' => $userId ], $fname );