diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index f36ddd157c..dd19c40072 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -196,6 +196,10 @@ class ReminderService { foreach($recurrenceExceptions as $recurrenceException) { $eventHash = $this->getEventHash($recurrenceException); + if (!isset($recurrenceException->VALARM)) { + continue; + } + foreach($recurrenceException->VALARM as $valarm) { /** @var VAlarm $valarm */ $alarmHash = $this->getAlarmHash($valarm); @@ -216,6 +220,10 @@ class ReminderService { $masterAlarms = []; $masterHash = $this->getEventHash($masterItem); + if (!isset($masterItem->VALARM)) { + return; + } + foreach($masterItem->VALARM as $valarm) { $masterAlarms[] = $this->getAlarmHash($valarm); } diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index a9acca66a8..4dcb688caa 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -164,6 +164,23 @@ TRIGGER:-P8D END:VALARM END:VEVENT END:VCALENDAR +EOD; + + public const CALENDAR_DATA_NO_ALARM = <<reminderService->onTouchCalendarObject($action, $objectData); } + public function testOnCalendarObjectCreateEmpty():void { + $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; + $objectData = [ + 'calendardata' => self::CALENDAR_DATA_NO_ALARM, + 'id' => '42', + 'calendarid' => '1337', + 'component' => 'vevent', + ]; + + $this->backend->expects($this->never()) + ->method('insertReminder'); + + $this->reminderService->onTouchCalendarObject($action, $objectData); + } + public function testOnCalendarObjectCreateRecurringEntryWithRepeat():void { $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [