diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-09-19 11:26:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-19 11:26:17 +0300 |
commit | 4e8aae50a8eaef1880181ba1e0b85d6e3c7d77a6 (patch) | |
tree | d94d14ee25e5593cdfb136c7188e0262334a74fb | |
parent | 1b47b99456b297589ea8ec72f1b532b90083eed9 (diff) | |
parent | 6d856ceaf9af79a4e85380201a9f470471b85ac5 (diff) |
Merge pull request #16994 from nextcloud/backport/16835/stable16
[stable16] Remove orphaned calendar data from deleted subscriptions
-rw-r--r-- | apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php b/apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php index 17643587904..3b5b7bc8ac7 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'); @@ -70,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(); |