From c6cf0aeb8a42ae9b813f0ef2fd2a955bbd0cd2a1 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Wed, 20 Apr 2022 16:10:14 +0000
Subject: [PATCH] prevent warning and error when deleting consultation slots,
 fixes #932

Closes #932
---
 lib/models/ConsultationSlot.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php
index fd3b05a7294..63c730aa9cd 100644
--- a/lib/models/ConsultationSlot.php
+++ b/lib/models/ConsultationSlot.php
@@ -51,7 +51,7 @@ class ConsultationSlot extends SimpleORMap
         };
         $config['registered_callbacks']['after_delete'][] = function ($slot) {
             $block = $slot->block;
-            if (count($block->slots) === 0) {
+            if ($block && count($block->slots) === 0) {
                 $block->delete();
             }
         };
-- 
GitLab