diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index c0ec60a9..8e062d94 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -456,7 +456,15 @@ if ( $qry->Exec("calquery",__LINE__,__FILE__) && $qry->rows() > 0 ) { $expanded = expand_event_instances($vResource, $expand_range_start, $expand_range_end, $expand_as_floating , $dav_object->collection_tzid); - if ( $expanded->ComponentCount() == 0 ) continue; + # An empty expansion only proves a non-match when the expansion + # window equals the requested range. For an open-ended time-range + # ($range_filter->until is null) the window is artificially capped + # (expand_range_end defaults to time_range_start + 730 days), so a + # future or sparsely-recurring event whose next instance lies beyond + # the cap must NOT be dropped here -- the getVCalendarRange()->overlaps() + # test above is already exact for open ranges. Only enforce the + # empty-window skip for a real upper bound or an explicit expansion. + if ( $expanded->ComponentCount() == 0 && ( $need_expansion || isset($range_filter->until) ) ) continue; # We only keep the expanded instaneces if need_expansion is set, # RFC4791 Section 7.4. Otherwise we should return the original