From 5cd75100c6b5113ec84fa8ee5dabc88eb5d07e24 Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Mon, 28 Feb 2022 15:27:48 +0100 Subject: [PATCH] attemted to prevent event creationg in ConsultationSlot::updateEvents --- lib/models/ConsultationBooking.php | 2 +- lib/models/ConsultationSlot.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/models/ConsultationBooking.php b/lib/models/ConsultationBooking.php index 3e02ba014ce..7a5e0150a35 100644 --- a/lib/models/ConsultationBooking.php +++ b/lib/models/ConsultationBooking.php @@ -88,7 +88,7 @@ class ConsultationBooking extends SimpleORMap implements PrivacyObject }; $config['registered_callbacks']['after_delete'][] = function (ConsultationBooking $booking) { - $booking->slot->updateEvents(); + $booking->slot->updateEvents(true); }; parent::configure($config); diff --git a/lib/models/ConsultationSlot.php b/lib/models/ConsultationSlot.php index 1177fcec98f..a271a75dec2 100644 --- a/lib/models/ConsultationSlot.php +++ b/lib/models/ConsultationSlot.php @@ -190,8 +190,11 @@ class ConsultationSlot extends SimpleORMap /** * Updates the teacher event that belongs to the slot. This will either be * set to be unoccupied, occupied by only one user or by a group of user. + * + * @param bool $delete_action Whether this method is called from a delete action (true) + * or not (false). Defaults to false. */ - public function updateEvents() + public function updateEvents(bool $delete_action = false) { // If no range is associated, remove the event if (!$this->block->range) { @@ -219,6 +222,9 @@ class ConsultationSlot extends SimpleORMap } } + if ($delete_action) { + return; + } // Add events for missing responsible users $missing = array_diff($responsible_ids, $this->events->pluck('user_id')); foreach ($missing as $user_id) { -- GitLab