mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
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>
This commit is contained in:
parent
7cc20468f1
commit
09031211da
1 changed files with 22 additions and 20 deletions
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue