mirror of
https://github.com/flarum/core.git
synced 2025-07-22 17:21:27 +02: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:
@@ -85,6 +85,10 @@ class NotificationSyncer
|
|||||||
// it isn't marked as deleted. If they don't, we will want to create a
|
// it isn't marked as deleted. If they don't, we will want to create a
|
||||||
// new record for them.
|
// new record for them.
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
if (! ($user instanceof User)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$existing = $toDelete->first(function ($i, $notification) use ($user) {
|
$existing = $toDelete->first(function ($i, $notification) use ($user) {
|
||||||
return $notification->user_id === $user->id;
|
return $notification->user_id === $user->id;
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user