diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-08-19 09:20:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 09:20:08 +0200 |
commit | 8514a2a436b57955a65cb9f6e7cf1b9e98721c38 (patch) | |
tree | d815d267d675567d963912c642779effda8147c4 /apps/dav | |
parent | 6725ad213f794dd82ae6efa8d649c2a047da143f (diff) | |
parent | 6f66fba559377d257be07c9a5f13db58bbc39b09 (diff) | |
download | nextcloud-server-8514a2a436b57955a65cb9f6e7cf1b9e98721c38.tar.gz nextcloud-server-8514a2a436b57955a65cb9f6e7cf1b9e98721c38.zip |
Merge pull request #16784 from nextcloud/bugfix/noid/fix_foreach_valarm_error
fix foreach error for reminder generator
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/Reminder/ReminderService.php | 8 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php | 32 |
2 files changed, 40 insertions, 0 deletions
diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index f36ddd157cc..dd19c400720 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 a9acca66a81..4dcb688caa1 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -166,6 +166,23 @@ END:VEVENT END:VCALENDAR EOD; + public const CALENDAR_DATA_NO_ALARM = <<<EOD +BEGIN:VCALENDAR +PRODID:-//Nextcloud calendar v1.6.4 +BEGIN:VEVENT +CREATED:20160602T133732 +DTSTAMP:20160602T133732 +LAST-MODIFIED:20160602T133732 +UID:wej2z68l9h +SUMMARY:Test Event +LOCATION:Somewhere ... +DESCRIPTION:maybe .... +DTSTART;TZID=Europe/Berlin;VALUE=DATE:20160609 +DTEND;TZID=Europe/Berlin;VALUE=DATE:20160610 +END:VEVENT +END:VCALENDAR +EOD; + public function setUp() { parent::setUp(); @@ -278,6 +295,21 @@ EOD; $this->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 = [ |