From 81b97217007364231ddb796567841ebd139e06e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20M=C3=BCller?= Date: Wed, 3 Feb 2016 20:18:56 +0100 Subject: [PATCH] Remove entries in dav_shares on deletion of a calendar --- apps/dav/lib/caldav/caldavbackend.php | 2 ++ apps/dav/lib/carddav/carddavbackend.php | 5 +---- apps/dav/lib/dav/sharing/backend.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/caldav/caldavbackend.php b/apps/dav/lib/caldav/caldavbackend.php index 4820116e9a6..3aa493e5087 100644 --- a/apps/dav/lib/caldav/caldavbackend.php +++ b/apps/dav/lib/caldav/caldavbackend.php @@ -340,6 +340,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $this->db->prepare('DELETE FROM `*PREFIX*calendarchanges` WHERE `calendarid` = ?'); $stmt->execute([$calendarId]); + + $this->sharingBackend->deleteAllShares($calendarId); } /** diff --git a/apps/dav/lib/carddav/carddavbackend.php b/apps/dav/lib/carddav/carddavbackend.php index d490bdb91ec..9ca166c22a2 100644 --- a/apps/dav/lib/carddav/carddavbackend.php +++ b/apps/dav/lib/carddav/carddavbackend.php @@ -336,10 +336,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { ->setParameter('id', $addressBookId) ->execute(); - $query->delete('dav_shares') - ->where($query->expr()->eq('resourceid', $query->createNamedParameter($addressBookId))) - ->andWhere($query->expr()->eq('type', $query->createNamedParameter('addressbook'))) - ->execute(); + $this->sharingBackend->deleteAllShares($addressBookId); $query->delete($this->dbCardsPropertiesTable) ->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))) diff --git a/apps/dav/lib/dav/sharing/backend.php b/apps/dav/lib/dav/sharing/backend.php index a68e484902c..0b28891fbc4 100644 --- a/apps/dav/lib/dav/sharing/backend.php +++ b/apps/dav/lib/dav/sharing/backend.php @@ -96,6 +96,17 @@ class Backend { $query->execute(); } + /** + * @param $resourceId + */ + public function deleteAllShares($resourceId) { + $query = $this->db->getQueryBuilder(); + $query->delete('dav_shares') + ->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId))) + ->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType))) + ->execute(); + } + /** * @param IShareable $shareable * @param string $element -- 2.39.5