Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] Fix/caldav/eventcomparisionservice uses wrong array comparison #44473

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/EventComparisonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function removeIfUnchanged(VEvent $filterEvent, array &$eventsToFilter):
$eventToFilterData[] = IMipService::readPropertyWithDefault($eventToFilter, $eventDiff, '');
}
// events are identical and can be removed
if (empty(array_diff($filterEventData, $eventToFilterData))) {
if ($filterEventData === $eventToFilterData) {
unset($eventsToFilter[$k]);
return true;
}
Expand Down
67 changes: 67 additions & 0 deletions apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/**
* @copyright 2023 Daniel Kesselberg <[email protected]>
* @copyright 2024 Robert C. Schaller <[email protected]>
*
* @author 2023 Daniel Kesselberg <[email protected]>
*
Expand Down Expand Up @@ -137,4 +138,70 @@ public function testModifiedUnmodifiedEvent(): void {
$this->assertEquals([$vEventOld2], $result['old']);
$this->assertEquals([$vEventNew2], $result['new']);
}

// First test to certify fix for issue nextcloud/server#41084
public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithoutZeroInit(): void {
$vCalendarOld = new VCalendar();
$vCalendarNew = new VCalendar();

$vEventOld = $vCalendarOld->add('VEVENT', [
'UID' => 'uid-1234',
'LAST-MODIFIED' => 123456,
// 'SEQUENCE' => 0, // sequence number may not be set to zero during event creation and instead fully omitted
'SUMMARY' => 'Fellowship meeting',
'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
]);
$vEventOld->add('ORGANIZER', 'mailto:[email protected]');
$vEventOld->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);

$vEventNew = $vCalendarNew->add('VEVENT', [
'UID' => 'uid-1234',
'LAST-MODIFIED' => 123456,
'SEQUENCE' => 1,
'SUMMARY' => 'Fellowship meeting',
'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
]);
$vEventNew->add('ORGANIZER', 'mailto:[email protected]');
$vEventNew->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);

$result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld);
$this->assertEquals([$vEventOld], $result['old']);
$this->assertEquals([$vEventNew], $result['new']);
}

// Second test to certify fix for issue nextcloud/server#41084
public function testSequenceNumberIncrementDetectedForFirstModificationToEventWithZeroInit(): void {
$vCalendarOld = new VCalendar();
$vCalendarNew = new VCalendar();

$vEventOld = $vCalendarOld->add('VEVENT', [
'UID' => 'uid-1234',
'LAST-MODIFIED' => 123456,
'SEQUENCE' => 0,
'SUMMARY' => 'Fellowship meeting',
'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
]);
$vEventOld->add('ORGANIZER', 'mailto:[email protected]');
$vEventOld->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);

$vEventNew = $vCalendarNew->add('VEVENT', [
'UID' => 'uid-1234',
'LAST-MODIFIED' => 123456,
'SEQUENCE' => 1,
'SUMMARY' => 'Fellowship meeting',
'DTSTART' => new \DateTime('2016-01-01 00:00:00'),
'RRULE' => 'FREQ=DAILY;INTERVAL=1;UNTIL=20160201T000000Z',
]);
$vEventNew->add('ORGANIZER', 'mailto:[email protected]');
$vEventNew->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);

$result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld);
$this->assertEquals([$vEventOld], $result['old']);
$this->assertEquals([$vEventNew], $result['new']);
}


}
Loading