From c3ae67d521378e252fea12a849b78bf21fb3525b Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+github@gmail.com>
Date: Fri, 18 Feb 2022 12:18:25 +0100
Subject: [PATCH] fail proof event creation for consultation slot, fixes #691

---
 lib/models/ConsultationSlot.php | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php
index 1177fcec98f..ebda30a3815 100644
--- a/lib/models/ConsultationSlot.php
+++ b/lib/models/ConsultationSlot.php
@@ -222,7 +222,12 @@ class ConsultationSlot extends SimpleORMap
         // Add events for missing responsible users
         $missing = array_diff($responsible_ids, $this->events->pluck('user_id'));
         foreach ($missing as $user_id) {
-            $event = $this->createEvent(User::find($user_id));
+            $user = User::find($user_id);
+            if (!$user) {
+                continue;
+            }
+
+            $event = $this->createEvent($user);
             ConsultationEvent::create([
                 'slot_id'  => $this->id,
                 'user_id'  => $user_id,
-- 
GitLab