mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Try and avoid race conditions with thank-you-edit notifications
Wait until after the main transaction has been committed before checking whether they have the right number of edits. Bug: T128249 Change-Id: I38cc0f96e97fda3692340cc8906144a002594ef2
This commit is contained in:
parent
f808909c67
commit
8d99490108
|
@ -461,6 +461,14 @@ class EchoHooks {
|
|||
// This edit hasn't been added to the edit count yet
|
||||
$editCount = $user->getEditCount() + 1;
|
||||
if ( in_array( $editCount, $thresholds ) ) {
|
||||
$id = $user->getId();
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $id, $title, $editCount ) {
|
||||
// Fresh User object
|
||||
$user = User::newFromId( $id );
|
||||
if ( $user->getEditCount() !== $editCount ) {
|
||||
// Race condition with multiple simultaneous requests, skip
|
||||
return;
|
||||
}
|
||||
LoggerFactory::getInstance( 'Echo' )->debug(
|
||||
'Thanking {user} (id: {id}) for their {count} edit',
|
||||
array(
|
||||
|
@ -469,7 +477,6 @@ class EchoHooks {
|
|||
'count' => $editCount,
|
||||
)
|
||||
);
|
||||
DeferredUpdates::addCallableUpdate( function () use ( $user, $title, $editCount ) {
|
||||
EchoEvent::create( array(
|
||||
'type' => 'thank-you-edit',
|
||||
'title' => $title,
|
||||
|
|
Loading…
Reference in a new issue