aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2019-09-04 10:54:47 +0200
committerGitHub <noreply@github.com>2019-09-04 10:54:47 +0200
commit0e19e55e242af3e665035f5928d293ed9addc4ed (patch)
tree64c622c2769fa377b50c02b38167683ce78d560b /apps/dav
parentca0fbaca8c0b6a548e175a1b259879d1aee40cd7 (diff)
parente2b539bebf53e0823d6561fbfde6f660ebc416ab (diff)
downloadnextcloud-server-0e19e55e242af3e665035f5928d293ed9addc4ed.tar.gz
nextcloud-server-0e19e55e242af3e665035f5928d293ed9addc4ed.zip
Merge pull request #16835 from nextcloud/bugfix/16833/remove-orphan-event-data-from-subscriptions
Remove orphaned calendar data from deleted subscriptions
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Migration/RemoveOrphanEventsAndContacts.php11
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();