diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php
index ebda30a3815bec152e7473142c8ed35762c9bbd9..a902f0631b5c6ba637c90fac0ca46e840d860828 100644
--- a/lib/models/ConsultationSlot.php
+++ b/lib/models/ConsultationSlot.php
@@ -46,7 +46,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();
             }
         };