53 Assert::parameterType( __CLASS__, $update,
'$update' );
54 '@phan-var UserEditCountUpdate $update';
56 foreach ( $update->infoByUser as $userId => $info ) {
57 if ( !isset( $this->infoByUser[$userId] ) ) {
59 $this->infoByUser[$userId] = [
'increment' => 0 ];
62 $this->infoByUser[$userId][
'increment'] += $info[
'increment'];
65 $this->infoByUser[$userId][
'object'] = $info[
'object'];
73 $mwServices = MediaWikiServices::getInstance();
74 $lb = $mwServices->getDBLoadBalancer();
76 $editTracker = $mwServices->getUserEditTracker();
79 (
new AutoCommitUpdate( $dbw, __METHOD__,
function () use ( $lb, $dbw, $fname, $editTracker ) {
80 foreach ( $this->infoByUser as $userId => $info ) {
83 [
'user_editcount=user_editcount+' . (
int)$info[
'increment'] ],
84 [
'user_id' => $userId,
'user_editcount IS NOT NULL' ],
88 $targetUserIdentity = $info[
'object'];
90 if ( $dbw->affectedRows() == 0 ) {
94 $dbr = $lb->getConnectionRef( DB_REPLICA );
97 $dbr->flushSnapshot( $fname );
98 $lb->waitForPrimaryPos( $dbr );
99 $editTracker->initializeUserEditCount( $targetUserIdentity );
103 $editTracker->clearUserEditCache( $targetUserIdentity );