From 456fb7e2940f3c49de3fad0c26230452d2196f49 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 22 Aug 2019 11:58:48 +0200 Subject: Remove orphaned calendar data from deleted subscriptions Closes #16833. Ref #13511 Signed-off-by: Thomas Citharel --- apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apps/dav') diff --git a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php index 17643587904..7d995ff35cd 100644 --- a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php +++ b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php @@ -55,6 +55,11 @@ class RemoveOrphanEventsAndContacts implements IRepairStep { $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendars', 'calendarid'); $output->info(sprintf('%d changes without a calendar have been cleaned up', $orphanItems)); + $orphanItems = $this->removeOrphanChildren('calendarobjects', 'calendarsubscriptions', 'calendarid'); + $output->info(sprintf('%d cached events without a calendar subscription have been cleaned up', $orphanItems)); + $orphanItems = $this->removeOrphanChildren('calendarchanges', 'calendarsubscriptions', 'calendarid'); + $output->info(sprintf('%d changes without a calendar subscription have been cleaned up', $orphanItems)); + $orphanItems = $this->removeOrphanChildren('cards', 'addressbooks', 'addressbookid'); $output->info(sprintf('%d contacts without an addressbook have been cleaned up', $orphanItems)); $orphanItems = $this->removeOrphanChildren('cards_properties', 'cards', 'cardid'); -- cgit v1.2.3 From e2b539bebf53e0823d6561fbfde6f660ebc416ab Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 22 Aug 2019 15:49:51 +0200 Subject: Check the calendar type of calendarobjects & calendarchanges Signed-off-by: Thomas Citharel --- apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apps/dav') diff --git a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php index 7d995ff35cd..3b5b7bc8ac7 100644 --- a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php +++ b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php @@ -75,6 +75,12 @@ class RemoveOrphanEventsAndContacts implements IRepairStep { ->from($childTable, 'c') ->leftJoin('c', $parentTable, 'p', $qb->expr()->eq('c.' . $parentId, 'p.id')) ->where($qb->expr()->isNull('p.id')); + + if (\in_array($parentTable, ['calendars', 'calendarsubscriptions'], true)) { + $calendarType = $parentTable === 'calendarsubscriptions' ? CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION : CalDavBackend::CALENDAR_TYPE_CALENDAR; + $qb->andWhere($qb->expr()->eq('c.calendartype', $qb->createNamedParameter($calendarType, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT)); + } + $result = $qb->execute(); $orphanItems = array(); -- cgit v1.2.3