Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable24] fix(dav) Handle Calendar trashbin UID conflicts by removing the deleted calendar object #37570

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1275,17 +1275,19 @@ public function createCalendarObject($calendarId, $objectUri, $calendarData, $ca
}
// 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();
Expand Down