summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-04-17 14:46:01 +0200
committerGitHub <noreply@github.com>2024-04-17 14:46:01 +0200
commitf60173eb591d5db4bd247592a566975f64170784 (patch)
treed1c3d9324550913d00c17d5cd0b2390db79358ee
parent3fb243e21cdc9eb698ed337b967a1079d4825963 (diff)
parentc98305c31ae69b63d2a73396c72acff4fb2b80cd (diff)
downloadnextcloud-server-f60173eb591d5db4bd247592a566975f64170784.tar.gz
nextcloud-server-f60173eb591d5db4bd247592a566975f64170784.zip
Merge pull request #44472 from nextcloud/backport/44017/stable27
[stable27] Fix/caldav/eventcomparisionservice uses wrong array comparison
-rw-r--r--apps/dav/lib/CalDAV/EventComparisonService.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php67
2 files changed, 68 insertions, 1 deletions
diff --git a/apps/dav/lib/CalDAV/EventComparisonService.php b/apps/dav/lib/CalDAV/EventComparisonService.php
index d8d6ea07ed2..fbb92af9d94 100644
--- a/apps/dav/lib/CalDAV/EventComparisonService.php
+++ b/apps/dav/lib/CalDAV/EventComparisonService.php
@@ -71,7 +71,7 @@ class EventComparisonService {
$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;
}
diff --git a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
index c21be3065c5..ed865f3a926 100644
--- a/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/EventComparisonServiceTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
/**
* @copyright 2023 Daniel Kesselberg <mail@danielkesselberg.de>
+ * @copyright 2024 Robert C. Schaller <gtbc_robert.schaller@rsxc.de>
*
* @author 2023 Daniel Kesselberg <mail@danielkesselberg.de>
*
@@ -143,4 +144,70 @@ class EventComparisonServiceTest extends TestCase
$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:gandalf@wiz.ard');
+ $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['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:gandalf@wiz.ard');
+ $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['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:gandalf@wiz.ard');
+ $vEventOld->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['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:gandalf@wiz.ard');
+ $vEventNew->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
+
+ $result = $this->eventComparisonService->findModified($vCalendarNew, $vCalendarOld);
+ $this->assertEquals([$vEventOld], $result['old']);
+ $this->assertEquals([$vEventNew], $result['new']);
+ }
+
+
}