From 4bf304374b580de9ce8878080627adfb008682be Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 8 Feb 2023 09:57:08 +0100 Subject: [PATCH] fixup! fix(CalDAV reminders): Fix timezone drift for all-day events Signed-off-by: Christoph Wurst --- apps/dav/lib/CalDAV/CalDavBackend.php | 2 +- apps/dav/lib/CalDAV/Reminder/ReminderService.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 51eb505124e38..b60d731b21512 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -658,7 +658,7 @@ public function getCalendarByUri($principal, $uri) { } /** - * @return array{id: int, uri: string, '{http://calendarserver.org/ns/}getctag': string, '{http://sabredav.org/ns}sync-token': int, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set': SupportedCalendarComponentSet, '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp': ScheduleCalendarTransp }|null + * @return array{id: int, uri: string, '{http://calendarserver.org/ns/}getctag': string, '{http://sabredav.org/ns}sync-token': int, '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set': SupportedCalendarComponentSet, '{urn:ietf:params:xml:ns:caldav}schedule-calendar-transp': ScheduleCalendarTransp, '{urn:ietf:params:xml:ns:caldav}calendar-timezone': ?string }|null */ public function getCalendarById(int $calendarId): ?array { $fields = array_column($this->propertyMap, 0); diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 9eff737816b45..3ed689ad3fe9a 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -308,7 +308,7 @@ public function onCalendarObjectCreate(array $objectData):void { try { $triggerTime = $valarm->getEffectiveTriggerTime(); - if (!$triggerTime->getTimezone() || $triggerTime->getTimezone()->getName() === 'UTC') { + if ($triggerTime->getTimezone() === false || $triggerTime->getTimezone()->getName() === 'UTC') { $triggerTime = new DateTimeImmutable( $triggerTime->format('Y-m-d H:i:s'), $calendarTimeZone @@ -396,7 +396,7 @@ private function getRemindersForVAlarm(VAlarm $valarm, $isRelative = $this->isAlarmRelative($valarm); /** @var DateTimeImmutable $notificationDate */ $notificationDate = $valarm->getEffectiveTriggerTime(); - if (!$notificationDate->getTimezone() || $notificationDate->getTimezone()->getName() === 'UTC') { + if ($notificationDate->getTimezone() === false || $notificationDate->getTimezone()->getName() === 'UTC') { $notificationDate = new DateTimeImmutable( $notificationDate->format('Y-m-d H:i:s'), $calendarTimeZone @@ -857,7 +857,10 @@ private function getCalendarTimeZone(int $calendarid): DateTimeZone { } // This property contains a VCALENDAR with a single // VTIMEZONE. + /** @var VObject\Component\VCalendar $vtimezoneObj */ $vtimezoneObj = VObject\Reader::read($calendarInfo[$tzProp]); - return $vtimezoneObj->VTIMEZONE->getTimeZone(); + /** @var VObject\Component\VTimeZone $vtimezone */ + $vtimezone = $vtimezoneObj->VTIMEZONE; + return $vtimezone->getTimeZone(); } }