diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 4d4b605de6dbc..cb4fc9558f9af 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -1268,21 +1268,29 @@ protected function updateProperties($addressBookId, $cardUri, $vCardSerialized) ] ); - foreach ($vCard->children() as $property) { - if (!in_array($property->name, self::$indexProperties)) { - continue; - } - $preferred = 0; - foreach ($property->parameters as $parameter) { - if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') { - $preferred = 1; - break; + + $this->db->beginTransaction(); + + try { + foreach ($vCard->children() as $property) { + if (!in_array($property->name, self::$indexProperties)) { + continue; + } + $preferred = 0; + foreach ($property->parameters as $parameter) { + if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') { + $preferred = 1; + break; + } } + $query->setParameter('name', $property->name); + $query->setParameter('value', mb_strcut($property->getValue(), 0, 254)); + $query->setParameter('preferred', $preferred); + $query->execute(); } - $query->setParameter('name', $property->name); - $query->setParameter('value', mb_strcut($property->getValue(), 0, 254)); - $query->setParameter('preferred', $preferred); - $query->execute(); + $this->db->commit(); + } catch (\Exception $e) { + $this->db->rollBack(); } }