mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-12 09:26:05 +00:00
Merge "Fix off-by-one edit count for ThankYouEdit notification"
This commit is contained in:
commit
b93e548d91
|
@ -547,7 +547,7 @@ class EchoHooks {
|
|||
// test for them reaching a congratulatory threshold
|
||||
$thresholds = [ 1, 10, 100, 1000, 10000, 100000, 1000000 ];
|
||||
if ( $user->isLoggedIn() && $status->value['revision'] ) {
|
||||
$thresholdCount = $user->getEditCount();
|
||||
$thresholdCount = self::getEditCount( $user );
|
||||
if ( in_array( $thresholdCount, $thresholds ) ) {
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $thresholdCount ) {
|
||||
$notificationMapper = new EchoNotificationMapper();
|
||||
|
@ -607,6 +607,20 @@ class EchoHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return int
|
||||
*/
|
||||
private static function getEditCount( User $user ) {
|
||||
// When this code runs from a maintenance script or unit tests
|
||||
// the deferred update incrementing edit count runs right away
|
||||
// so the edit count is right. Otherwise it lags by one.
|
||||
if ( wfIsCLI() ) {
|
||||
return $user->getEditCount();
|
||||
}
|
||||
return $user->getEditCount() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for EchoAbortEmailNotification hook
|
||||
* @param User $user
|
||||
|
|
Loading…
Reference in a new issue