From daeb94561f148c41f131d7e535976b30e892f183 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 24 Mar 2017 09:13:37 -0700 Subject: [PATCH] When destroying Calendar events, destroy invitees and notifications Summary: Fixes T12395. Test Plan: Ran `bin/remove destroy E... --trace`, saw invitee and notification destruction. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12395 Differential Revision: https://secure.phabricator.com/D17555 --- .../storage/PhabricatorCalendarEvent.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/applications/calendar/storage/PhabricatorCalendarEvent.php b/src/applications/calendar/storage/PhabricatorCalendarEvent.php index 5b64fdea53..b2e81b0e8b 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEvent.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEvent.php @@ -1343,7 +1343,21 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO PhabricatorDestructionEngine $engine) { $this->openTransaction(); - $this->delete(); + $invitees = id(new PhabricatorCalendarEventInvitee())->loadAllWhere( + 'eventPHID = %s', + $this->getPHID()); + foreach ($invitees as $invitee) { + $invitee->delete(); + } + + $notifications = id(new PhabricatorCalendarNotification())->loadAllWhere( + 'eventPHID = %s', + $this->getPHID()); + foreach ($notifications as $notification) { + $notification->delete(); + } + + $this->delete(); $this->saveTransaction(); }