Skip to content

Commit

Permalink
Reordering of vevent should not be a significant change (sabre-io#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
floerke committed Sep 10, 2021
1 parent d8a0a9a commit 28c5137
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,10 @@ protected function parseEventInfo(VCalendar $calendar = null)
$instances = [];
$exdate = [];

$significantChangeEventProperties = [];

foreach ($calendar->VEVENT as $vevent) {
$eventSignificantChangeHash = "";
$rrule = [];

if (is_null($uid)) {
Expand Down Expand Up @@ -930,19 +933,27 @@ protected function parseEventInfo(VCalendar $calendar = null)
if (isset($vevent->$prop)) {
$propertyValues = $vevent->select($prop);

$significantChangeHash .= $prop.':';
$eventSignificantChangeHash .= $prop.':';

if ('EXDATE' === $prop) {
$significantChangeHash .= implode(',', $exdate).';';
$eventSignificantChangeHash .= implode(',', $exdate).';';
} elseif ('RRULE' === $prop) {
$significantChangeHash .= implode(',', $rrule).';';
$eventSignificantChangeHash .= implode(',', $rrule).';';
} else {
foreach ($propertyValues as $val) {
$significantChangeHash .= $val->getValue().';';
$eventSignificantChangeHash .= $val->getValue().';';
}
}
}
}
$significantChangeEventProperties[] = $eventSignificantChangeHash;

}

asort($significantChangeEventProperties);

foreach ($significantChangeEventProperties as $eventSignificantChangeHash) {
$significantChangeHash .= $eventSignificantChangeHash;
}
$significantChangeHash = md5($significantChangeHash);

Expand Down
65 changes: 65 additions & 0 deletions tests/VObject/ITip/BrokerSignificantChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,69 @@ public function testSignificantChangesRRuleOrderNoChange()

$this->parse($old, $new, $expected, 'mailto:martin@fruux.com');
}

/**
* Check significant changes detection (no change).
* Reordering of vevent in a recurring event with exceptions should
* not be a significant change
* https://github.com/sabre-io/vobject/issues/542.
*/
public function testSignificantChangesVeventOrderNoChange()
{
$vevent1 = <<<ICS
BEGIN:VEVENT
UID:20140813T153116Z-12176-1000-1065-6@johnny-lubuntu
DTSTAMP:20140813T142829Z
DTSTART;TZID=America/Toronto:20140815T110000
SEQUENCE:2
SUMMARY:Evo makes a Meeting
LOCATION:fruux HQ
CLASS:PUBLIC
RRULE:FREQ=WEEKLY;BYDAY=MO
ORGANIZER:MAILTO:martin@fruux.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;LANGUAGE=en:MAILTO:dominik@fruux.com
CREATED:20140813T153211Z
LAST-MODIFIED:20140813T155353Z
END:VEVENT
ICS;
$vevent2 = <<<ICS
BEGIN:VEVENT
UID:20140813T153116Z-12176-1000-1065-6@johnny-lubuntu
DTSTAMP:20210813T142829Z
DTSTART;TZID=America/Toronto:20140815T110000
SEQUENCE:2
SUMMARY:Evo makes a Meeting
LOCATION:fruux HQ
CLASS:PUBLIC
RRULE:FREQ=WEEKLY;BYDAY=MO
ORGANIZER:MAILTO:martin@fruux.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;LANGUAGE=en:MAILTO:dominik@fruux.com
CREATED:20140813T153211Z
LAST-MODIFIED:20140813T155353Z
END:VEVENT
ICS;

$head = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//Ximian//NONSGML Evolution Calendar//EN
ICS;

$old = $head;
$old .= "\n".$vevent1;
$old .= "\n".$vevent2;
$old .= "\nEND:VCALENDAR";

$new = $head;
$new .= "\n".$vevent1;
$new .= "\n".$vevent2;
$new .= "\nEND:VCALENDAR";

$expected = [['significantChange' => false]];

$this->parse($old, $new, $expected, 'mailto:martin@fruux.com');
}
}

0 comments on commit 28c5137

Please sign in to comment.