From d7a272dddca4926f6c97e37dfa9cd5969cc2b888 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Tue, 27 Feb 2024 15:58:38 +0100 Subject: [PATCH] fixup! feat(dav): implement updating a principal's schedule-default-calendar-URL --- apps/dav/lib/DAV/CustomPropertiesBackend.php | 7 ++++++- apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php index c124a7dbd6b39..45637a0bbd086 100644 --- a/apps/dav/lib/DAV/CustomPropertiesBackend.php +++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php @@ -42,6 +42,7 @@ use Sabre\DAV\Xml\Property\Complex; use Sabre\DAV\Xml\Property\Href; use Sabre\DAV\Xml\Property\LocalHref; +use Sabre\Xml\ParseException; use Sabre\Xml\Service as XmlService; use function array_intersect; @@ -520,6 +521,10 @@ private function formatPath(string $path): string { return $path; } + /** + * @throws ParseException If parsing a \Sabre\DAV\Xml\Property\Complex value fails + * @throws DavException If the property value is invalid + */ private function encodeValueForDatabase(string $path, string $name, mixed $value): array { // Try to parse a more specialized property type first if ($value instanceof Complex) { @@ -534,7 +539,7 @@ private function encodeValueForDatabase(string $path, string $name, mixed $value try { $this->validateProperty($path, $name, $value); } catch (DavException $e) { - throw new \Exception( + throw new DavException( "Property \"$name\" has an invalid value: " . $e->getMessage(), 0, $e, diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 88dac8a73e5a2..4d2cb0f9d80cb 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -137,7 +137,7 @@ protected function getProps(string $user, string $path) { $data = []; while ($row = $result->fetch()) { $value = $row['propertyvalue']; - if ($row['valuetype'] === CustomPropertiesBackend::PROPERTY_TYPE_HREF) { + if ((int)$row['valuetype'] === CustomPropertiesBackend::PROPERTY_TYPE_HREF) { $value = new Href($value); } $data[$row['propertyname']] = $value;