mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 05:32:49 +08:00
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:
parent
cdbc4b9717
commit
56b39f9fba
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user