Hooks: Check if user is still registered

In certain circumstances, it's possible for the user account to
have been deleted by the time the deferred update runs.

Bug: T318081
Change-Id: I3d1b5d1f034bf239e25d4af484b6329582b49bdc
This commit is contained in:
Kosta Harlan 2022-12-20 12:53:45 +01:00 committed by Gergő Tisza
parent 6adf70e972
commit 77fce1c31b
No known key found for this signature in database
GPG key ID: C34FEC97E6257F96

View file

@ -1415,6 +1415,11 @@ class Hooks implements
// option changes. This covers both explicit changes in the preferences
// and changes made through the options API (since both call this hook).
DeferredUpdates::addCallableUpdate( static function () use ( $user ) {
if ( !$user->isRegistered() ) {
// It's possible the user account was deleted before the deferred
// update runs (T318081)
return;
}
MWEchoNotifUser::newFromUser( $user )->resetNotificationCount();
} );
}