From 0f3b942c9712fb8249bf91279211e778585678c8 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 29 Feb 2016 18:48:02 +1030 Subject: [PATCH] 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. --- framework/core/src/Core/Notification/NotificationSyncer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/core/src/Core/Notification/NotificationSyncer.php b/framework/core/src/Core/Notification/NotificationSyncer.php index 8287b42ab..e1039afd7 100644 --- a/framework/core/src/Core/Notification/NotificationSyncer.php +++ b/framework/core/src/Core/Notification/NotificationSyncer.php @@ -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; });