Fix crash when sending notification to non-existent user

When renaming a discussion, an attempt is made to send a notification to the discussion's author. However, there is no check to see if the user account still exists - this can lead to a crash. While the check should technically be in the initiating code, it will probably slip through the cracks in other scenarios/extensions, so it's probably best that we safe-guard against this in the NotificationSyncer itself.
This commit is contained in:
Toby Zerner 2016-02-29 18:48:02 +10:30
parent cdbc4b9717
commit 56b39f9fba

View File

@ -85,6 +85,10 @@ class NotificationSyncer
// it isn't marked as deleted. If they don't, we will want to create a
// new record for them.
foreach ($users as $user) {
if (! ($user instanceof User)) {
continue;
}
$existing = $toDelete->first(function ($i, $notification) use ($user) {
return $notification->user_id === $user->id;
});