From a15f9462633b9187cb5cd0819a7ceef8e028b1a5 Mon Sep 17 00:00:00 2001 From: Jonathan Boivin Date: Thu, 9 Nov 2023 21:46:36 -0500 Subject: [PATCH 1/2] Ensure no description changes are lot Signed-off-by: Jonathan Boivin --- apps/dav/lib/CalDAV/Schedule/Plugin.php | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php index 16acc72d9886c..6f08cbb485903 100644 --- a/apps/dav/lib/CalDAV/Schedule/Plugin.php +++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php @@ -162,6 +162,11 @@ public function calendarObjectChange(RequestInterface $request, ResponseInterfac if (!$this->pathOfCalendarObjectChange) { $this->pathOfCalendarObjectChange = $request->getPath(); } + + // Ensure description consistency + if (!$isNew) { + $this->ensureDescriptionConsistency($request, $vCal, $modified); + } parent::calendarObjectChange($request, $response, $vCal, $calendarPath, $modified, $isNew); } @@ -632,4 +637,38 @@ private function createCalendar(CalendarHome $calendarHome, string $principalUri '{DAV:}displayname' => $displayName, ]); } + + private function ensureDescriptionConsistency(RequestInterface $request, VCalendar $vCal, &$modified) { + $xAltDescPropName = "X-ALT-DESC"; + + // Obtain previous version + $node = $this->server->tree->getNodeForPath($request->getPath()); + $oldObj = Reader::read($node->get()); + + // Get presence of description fields + $hasOldDescription = isset($oldObj->VTODO) && isset($oldObj->VTODO->DESCRIPTION); + $hasNewDescription = isset($vCal->VTODO) && isset($vCal->VTODO->DESCRIPTION); + $hasOldXAltDesc = isset($oldObj->VTODO) && isset($oldObj->VTODO->{$xAltDescPropName}); + $hasNewXAltDesc = isset($vCal->VTODO) && isset($vCal->VTODO->{$xAltDescPropName}); + $hasAllDesc = $hasOldDescription && $hasNewDescription && $hasOldXAltDesc && $hasNewXAltDesc; + + // If all description fields are present, then verify consistency + if ($hasAllDesc) { + // Get descriptions + $oldDescription = (string) $oldObj->VTODO->DESCRIPTION; + $newDescription = (string) $vCal->VTODO->DESCRIPTION; + $oldXAltDesc = (string) $oldObj->VTODO->{$xAltDescPropName}; + $newXAltDesc = (string) $vCal->VTODO->{$xAltDescPropName}; + + // Compare descriptions + $isSameDescription = $oldDescription === $newDescription; + $isSameXAltDesc = $oldXAltDesc === $newXAltDesc; + + // If the description changed, but not the alternate one, then delete the latest + if (!$isSameDescription && $isSameXAltDesc) { + unset($vCal->VTODO->{$xAltDescPropName}); + $modified = true; + } + } + } } From 4c5b52ae1bf75ed8f68711911fed2a9cca02cfbf Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 11 Jun 2026 11:28:17 +0200 Subject: [PATCH 2/2] chore: add missing types Signed-off-by: Ferdinand Thiessen --- apps/dav/lib/CalDAV/Schedule/Plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php index 6f08cbb485903..f3747fe69dcac 100644 --- a/apps/dav/lib/CalDAV/Schedule/Plugin.php +++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php @@ -638,7 +638,7 @@ private function createCalendar(CalendarHome $calendarHome, string $principalUri ]); } - private function ensureDescriptionConsistency(RequestInterface $request, VCalendar $vCal, &$modified) { + private function ensureDescriptionConsistency(RequestInterface $request, VCalendar $vCal, &$modified): void { $xAltDescPropName = "X-ALT-DESC"; // Obtain previous version