fix: events with recurrence rule are sometimes counted one too many times in freebusy

This commit is contained in:
Piotr Filip 2020-07-22 17:58:46 +02:00 committed by Andrew Ruthven
parent bc1bbd3da0
commit e98bf7b682
2 changed files with 29 additions and 3 deletions

View File

@ -816,12 +816,12 @@ class RepeatRule {
if ( !isset($this->instances[$position]) || $instance != $this->instances[$position] ) {
$got_more = true;
$position++;
$this->instances[$position] = $instance;
if ( DEBUG_RRULE ) printf( "Added date %s into position %d in current set\n", $instance->format('c'), $position );
if ( isset($this->count) && ($position + 1) >= $this->count ) {
if ( isset($this->count) && $position >= $this->count ) {
$this->finished = true;
return;
}
$this->instances[$position] = $instance;
if ( DEBUG_RRULE ) printf( "Added date %s into position %d in current set\n", $instance->format('c'), $position );
}
}
}

View File

@ -88,6 +88,22 @@ END:VEVENT
END:VCALENDAR
");
$count_cal = new vCalendar("BEGIN:VCALENDAR
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
VERSION:2.0
BEGIN:VEVENT
CREATED:20190117T001216Z
LAST-MODIFIED:20190117T001233Z
DTSTAMP:20190117T001233Z
UID:dae6404d-1ce0-42d0-af3b-0d303034197b
SUMMARY:New Event
RRULE:FREQ=WEEKLY;COUNT=4;BYDAY=MO,TU,WE,TH
DTSTART;TZID=Pacific/Auckland:20190121T130000
DTEND;TZID=Pacific/Auckland:20190121T140000
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR");
/**
* A simplified model of get_freebusy, which works off of a passed-in vCalendar
* rather than making SQL queries
@ -150,4 +166,14 @@ final class ExpansionTest extends TestCase
get_freebusyish($tuesday_renamed_cal_order_swapped)
);
}
public function testCalWithCount() {
global $count_cal;
self::assertEquals(
self::expected_freebusyish_for_base,
get_freebusyish($count_cal)
);
}
}