aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CardDAV
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-02-29 09:27:49 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2024-02-29 09:27:49 +0100
commit09031211da7c111831cbf04887eed51a4b69cbf9 (patch)
tree11f53c454f6e7060714b979ed01e344dfc5ee318 /apps/dav/lib/CardDAV
parent7cc20468f13cddb433a35a58e048ce8c4ce43f1d (diff)
downloadnextcloud-server-09031211da7c111831cbf04887eed51a4b69cbf9.tar.gz
nextcloud-server-09031211da7c111831cbf04887eed51a4b69cbf9.zip
fix(dav): Fix atomic addressbook update
Sabre executes the proppatch callback *after* calling updateAddressbook and not synchronously. That means the code inside the callback was run outside a database transaction. This moves the atomic helper into the callback to create the expected transaction span. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib/CardDAV')
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php42
1 files changed, 22 insertions, 20 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index bb7031caeab..f51049b7833 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -331,24 +331,24 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* @return void
*/
public function updateAddressBook($addressBookId, \Sabre\DAV\PropPatch $propPatch) {
- $this->atomic(function () use ($addressBookId, $propPatch) {
- $supportedProperties = [
- '{DAV:}displayname',
- '{' . Plugin::NS_CARDDAV . '}addressbook-description',
- ];
+ $supportedProperties = [
+ '{DAV:}displayname',
+ '{' . Plugin::NS_CARDDAV . '}addressbook-description',
+ ];
- $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
- $updates = [];
- foreach ($mutations as $property => $newValue) {
- switch ($property) {
- case '{DAV:}displayname':
- $updates['displayname'] = $newValue;
- break;
- case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
- $updates['description'] = $newValue;
- break;
- }
+ $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
+ $updates = [];
+ foreach ($mutations as $property => $newValue) {
+ switch ($property) {
+ case '{DAV:}displayname':
+ $updates['displayname'] = $newValue;
+ break;
+ case '{' . Plugin::NS_CARDDAV . '}addressbook-description':
+ $updates['description'] = $newValue;
+ break;
}
+ }
+ [$addressBookRow, $shares] = $this->atomic(function () use ($addressBookId, $updates) {
$query = $this->db->getQueryBuilder();
$query->update('addressbooks');
@@ -362,11 +362,13 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$addressBookRow = $this->getAddressBookById((int)$addressBookId);
$shares = $this->getShares((int)$addressBookId);
- $this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
+ return [$addressBookRow, $shares];
+ }, $this->db);
- return true;
- });
- }, $this->db);
+ $this->dispatcher->dispatchTyped(new AddressBookUpdatedEvent((int)$addressBookId, $addressBookRow, $shares, $mutations));
+
+ return true;
+ });
}
/**