From 201d1c5ce783592800a5a22aa67e6ca254099b4f Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Fri, 6 Nov 2026 11:13:09 -0400 Subject: [PATCH] fixed whitescreens when clicking edit on the my reservations page for a reservation where the room no longer exists --- reservation.inc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/reservation.inc b/reservation.inc index 8e1cac1..029612f 100644 --- a/reservation.inc +++ b/reservation.inc @@ -88,7 +88,21 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte reserve_set_modal_message($form, $max_reservations_exceeded_message); } } - $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($eid); + $entity_type_manager = \Drupal::entityTypeManager(); + $entity = ($entity_type && $eid && $entity_type_manager->hasDefinition($entity_type)) + ? $entity_type_manager->getStorage($entity_type)->load($eid) + : NULL; + // The reservable item may have been deleted (or the URL is invalid); don't + // fatal - show a message and only leave the form actions (e.g. Delete). + if (!$entity) { + reserve_set_modal_message($form, t('The item this reservation is for no longer exists.')); + foreach (\Drupal\Core\Render\Element::children($form) as $key) { + if (!in_array($key, ['actions', 'message', 'form_build_id', 'form_token', 'form_id'])) { + $form[$key]['#access'] = FALSE; + } + } + return; + } $bundle = $entity->bundle(); $date = date('l, M d, Y', strtotime($d)); $time = reserve_display_time($t);