diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2024-03-05 22:00:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-05 22:00:08 +0100 |
commit | 65a05834cf412caf3ec743312335267aa4a79a68 (patch) | |
tree | e2cceeb3173c46d2c5854d6e8ae65a6c980c4da0 /apps | |
parent | 0d4e64863099672fcc2e16cb4838be3a866de5c5 (diff) | |
parent | 09031211da7c111831cbf04887eed51a4b69cbf9 (diff) | |
download | nextcloud-server-65a05834cf412caf3ec743312335267aa4a79a68.tar.gz nextcloud-server-65a05834cf412caf3ec743312335267aa4a79a68.zip |
Merge pull request #43903 from nextcloud/fix/dav/dirty-address-book-update
fix(dav): Fix atomic addressbook update
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 42 |
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; + }); } /** |