aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2024-03-05 21:44:40 +0100
committerGitHub <noreply@github.com>2024-03-05 21:44:40 +0100
commit00e0fa48a0046a7549cd8b704b92a7e57f220bf3 (patch)
tree88af997d0c8c0fd2fcf3d23a9b388478c6c55bae /apps/dav
parente072035e863e90191e9fc1ec460e8ee694b42672 (diff)
parenta2fcf50f43c1e5447316a400c993d477002fe69d (diff)
downloadnextcloud-server-00e0fa48a0046a7549cd8b704b92a7e57f220bf3.tar.gz
nextcloud-server-00e0fa48a0046a7549cd8b704b92a7e57f220bf3.zip
Merge pull request #43904 from nextcloud/fix/dav/dirty-caldav-updates
fix(dav): Fix atomic calendar/subscription updates
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php83
1 files changed, 43 insertions, 40 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index 78441dc4118..e3b8f9ce731 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -848,24 +848,24 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @return void
*/
public function updateCalendar($calendarId, PropPatch $propPatch) {
- $this->atomic(function () use ($calendarId, $propPatch) {
- $supportedProperties = array_keys($this->propertyMap);
- $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
-
- $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
- $newValues = [];
- foreach ($mutations as $propertyName => $propertyValue) {
- switch ($propertyName) {
- case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
- $fieldName = 'transparent';
- $newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
- break;
- default:
- $fieldName = $this->propertyMap[$propertyName][0];
- $newValues[$fieldName] = $propertyValue;
- break;
- }
+ $supportedProperties = array_keys($this->propertyMap);
+ $supportedProperties[] = '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp';
+
+ $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
+ $newValues = [];
+ foreach ($mutations as $propertyName => $propertyValue) {
+ switch ($propertyName) {
+ case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
+ $fieldName = 'transparent';
+ $newValues[$fieldName] = (int) ($propertyValue->getValue() === 'transparent');
+ break;
+ default:
+ $fieldName = $this->propertyMap[$propertyName][0];
+ $newValues[$fieldName] = $propertyValue;
+ break;
}
+ }
+ [$calendarData, $shares] = $this->atomic(function () use ($calendarId, $newValues) {
$query = $this->db->getQueryBuilder();
$query->update('calendars');
foreach ($newValues as $fieldName => $value) {
@@ -878,11 +878,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendarData = $this->getCalendarById($calendarId);
$shares = $this->getShares($calendarId);
- $this->dispatcher->dispatchTyped(new CalendarUpdatedEvent($calendarId, $calendarData, $shares, $mutations));
+ return [$calendarData, $shares];
+ }, $this->db);
- return true;
- });
- }, $this->db);
+ $this->dispatcher->dispatchTyped(new CalendarUpdatedEvent($calendarId, $calendarData, $shares, $mutations));
+
+ return true;
+ });
}
/**
@@ -2570,22 +2572,22 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
* @return void
*/
public function updateSubscription($subscriptionId, PropPatch $propPatch) {
- $this->atomic(function () use ($subscriptionId, $propPatch) {
- $supportedProperties = array_keys($this->subscriptionPropertyMap);
- $supportedProperties[] = '{http://calendarserver.org/ns/}source';
-
- $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
- $newValues = [];
-
- foreach ($mutations as $propertyName => $propertyValue) {
- if ($propertyName === '{http://calendarserver.org/ns/}source') {
- $newValues['source'] = $propertyValue->getHref();
- } else {
- $fieldName = $this->subscriptionPropertyMap[$propertyName][0];
- $newValues[$fieldName] = $propertyValue;
- }
+ $supportedProperties = array_keys($this->subscriptionPropertyMap);
+ $supportedProperties[] = '{http://calendarserver.org/ns/}source';
+
+ $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
+ $newValues = [];
+
+ foreach ($mutations as $propertyName => $propertyValue) {
+ if ($propertyName === '{http://calendarserver.org/ns/}source') {
+ $newValues['source'] = $propertyValue->getHref();
+ } else {
+ $fieldName = $this->subscriptionPropertyMap[$propertyName][0];
+ $newValues[$fieldName] = $propertyValue;
}
+ }
+ $subscriptionRow = $this->atomic(function () use ($subscriptionId, $newValues) {
$query = $this->db->getQueryBuilder();
$query->update('calendarsubscriptions')
->set('lastmodified', $query->createNamedParameter(time()));
@@ -2595,12 +2597,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
->executeStatement();
- $subscriptionRow = $this->getSubscriptionById($subscriptionId);
- $this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
+ return $this->getSubscriptionById($subscriptionId);
+ }, $this->db);
- return true;
- });
- }, $this->db);
+ $this->dispatcher->dispatchTyped(new SubscriptionUpdatedEvent((int)$subscriptionId, $subscriptionRow, [], $mutations));
+
+ return true;
+ });
}
/**