diff options
author | Daniel <mail@danielkesselberg.de> | 2023-02-21 16:32:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 16:32:05 +0100 |
commit | c6c512a19d13dbe7fe0bdd7330f53c3beb351686 (patch) | |
tree | 0276d886c9a9307ea9fe238d8240c71cf50c7745 /apps | |
parent | 5fcb55a2a9653575eec1c9d3551d6a887a22b84f (diff) | |
parent | 5b6a0affd01f2093a4e2fdbbc916ea8935f65166 (diff) | |
download | nextcloud-server-c6c512a19d13dbe7fe0bdd7330f53c3beb351686.tar.gz nextcloud-server-c6c512a19d13dbe7fe0bdd7330f53c3beb351686.zip |
Merge pull request #34375 from nextcloud/fix/trashbin-uid
fix(dav) Handle Calendar trashbin UID conflicts by removing the deleted calendar object
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index b60d731b215..d11aaa06a1a 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -1223,17 +1223,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } // For a more specific error message we also try to explicitly look up the UID but as a deleted entry $qbDel = $this->db->getQueryBuilder(); - $qbDel->select($qb->func()->count('*')) + $qbDel->select('*') ->from('calendarobjects') ->where($qbDel->expr()->eq('calendarid', $qbDel->createNamedParameter($calendarId))) ->andWhere($qbDel->expr()->eq('uid', $qbDel->createNamedParameter($extraData['uid']))) ->andWhere($qbDel->expr()->eq('calendartype', $qbDel->createNamedParameter($calendarType))) ->andWhere($qbDel->expr()->isNotNull('deleted_at')); $result = $qbDel->executeQuery(); - $count = (int) $result->fetchOne(); + $found = $result->fetch(); $result->closeCursor(); - if ($count !== 0) { - throw new BadRequest('Deleted calendar object with uid already exists in this calendar collection.'); + if ($found !== false) { + // the object existed previously but has been deleted + // remove the trashbin entry and continue as if it was a new object + $this->deleteCalendarObject($calendarId, $found['uri']); } $query = $this->db->getQueryBuilder(); |