Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/302722
Change subject: Keep $user->mEditCount up to date ...................................................................... Keep $user->mEditCount up to date Whenever User::incEditCount() is called, this tries to keep the user object up to date so hooks can read the edit count without reloading the user from the db. Another option would be invalidate the instance cache and let the read repopulate it. It would add a db access on each edit. Bug: T128249 Change-Id: I79194c41d6b2fd84ad658909a2941d9d3d28d94e --- M includes/user/User.php M tests/phpunit/includes/user/UserTest.php 2 files changed, 5 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/22/302722/1 diff --git a/includes/user/User.php b/includes/user/User.php index c46836b..5208400 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -5161,13 +5161,15 @@ // If we actually have a slave server, the count is // at least one behind because the current transaction // has not been committed and replicated. - $this->initEditCount( 1 ); + $this->mEditCount = $this->initEditCount( 1 ); } else { // But if DB_SLAVE is selecting the master, then the // count we just read includes the revision that was // just added in the working transaction. - $this->initEditCount(); + $this->mEditCount = $this->initEditCount(); } + } else { + $this->mEditCount++; } // Edit count in user cache too $this->invalidateCache(); diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index beb5e78..dabfd8a 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -221,17 +221,15 @@ $page->doEdit( (string)$i, 'test', 0, false, $user ); } - $user->clearInstanceCache(); $this->assertEquals( 3, $user->getEditCount(), 'After three edits, the user edit count should be 3' ); - // increase the edit count and clear the cache + // increase the edit count $user->incEditCount(); - $user->clearInstanceCache(); $this->assertEquals( 4, $user->getEditCount(), -- To view, visit https://gerrit.wikimedia.org/r/302722 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I79194c41d6b2fd84ad658909a2941d9d3d28d94e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits