diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2025-02-27 13:17:45 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2025-02-27 13:17:45 +0100 |
commit | 51d1746d63328d97d3c4b4685318f3c9d54bfdd7 (patch) | |
tree | 50129ceafac0af8e31c83ffb498f72241d548482 | |
parent | 299a62b54d0b2990f6158364d53bf6c0dbc801d0 (diff) | |
download | nextcloud-server-fix/dav/create-sab-in-transaction.tar.gz nextcloud-server-fix/dav/create-sab-in-transaction.zip |
fix(dav): Handle SAB creation in transactionfix/dav/create-sab-in-transaction
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r-- | apps/dav/lib/CardDAV/SyncService.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php index cc3d324faf1..8f3ddd83df4 100644 --- a/apps/dav/lib/CardDAV/SyncService.php +++ b/apps/dav/lib/CardDAV/SyncService.php @@ -276,9 +276,21 @@ class SyncService { public function getLocalSystemAddressBook() { if (is_null($this->localSystemAddressBook)) { $systemPrincipal = 'principals/system/system'; - $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [ + $localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [ '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance' ]); + + /* + * Do not keep a potentially volatile state + * + * If we are in a transaction, a newly created SAB would be + * rolled back if the transaction is rolled back. + */ + if (!$this->dbConnection->inTransaction()) { + $this->localSystemAddressBook = $localSystemAddressBook; + } else { + return $localSystemAddressBook; + } } return $this->localSystemAddressBook; |