diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php
index fd3b05a72940f77a51a4f4f3bf760ebe0ac2c5e3..63c730aa9cd3596df0505abc672b567f1b762ae5 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();
             }
         };