Increase, and make configurable, the limit for rrule expansion

This commit is contained in:
Jamie McClymont 2019-01-08 16:08:07 +13:00 committed by Jamie McClymont
parent 6a3619aaad
commit cf2f019419
3 changed files with 9 additions and 2 deletions

View File

@ -1157,6 +1157,7 @@ function rdate_expand( $dtstart, $property, $component, $range_end = null, $is_d
* @return array An array keyed on the UTC dates, referring to the component
*/
function rrule_expand( $dtstart, $property, $component, $range_end, $is_date=null, $return_floating_times=false, $fallback_tzid=null ) {
global $c;
$expansion = array();
$recur = $component->GetProperty($property);
@ -1176,11 +1177,15 @@ function rrule_expand( $dtstart, $property, $component, $range_end, $is_date=nul
if ( DEBUG_RRULE ) printf( "RRULE: %s (floating: %s)\n", $recur, ($return_floating_times?"yes":"no") );
$rule = new RepeatRule( $this_start, $recur, $is_date, $return_floating_times );
$i = 0;
$result_limit = 1000;
if ( !isset($c->rrule_expansion_limit) ) $c->rrule_expansion_limit = 5000;
while( $date = $rule->next($return_floating_times) ) {
// if ( DEBUG_RRULE ) printf( "[%3d] %s\n", $i, $date->UTC() );
$expansion[$date->FloatOrUTC($return_floating_times)] = $component;
if ( $i++ >= $result_limit || $date > $range_end ) break;
if ( $date > $range_end ) break;
if ( $i++ >= $c->rrule_expansion_limit ) {
dbg_error_log( 'ERROR', "Hit rrule expansion limit of ".$c->rrule_expansion_limit." - increase rrule_expansion_limit in config to avoid events missing from freebusy" );
}
}
// if ( DEBUG_RRULE ) print_r( $expansion );
return $expansion;

View File

@ -36,6 +36,7 @@ BEGIN:VFREEBUSY
DTSTAMP:yyyymmddThhmmssZ
DTSTART:20111018T110000Z
DTEND:20111019T110000Z
FREEBUSY:20111018T180000Z/20111019T040000Z
UID:E9F98477-A9C2-43F9-8371-CBA0CBCB0300
ORGANIZER:mailto:manager1@example.net
ATTENDEE:mailto:user1@example.net

View File

@ -35,6 +35,7 @@ BEGIN:VFREEBUSY
DTSTAMP:yyyymmddThhmmssZ
DTSTART:20111024T110000Z
DTEND:20111025T110000Z
FREEBUSY:20111024T180000Z/20111025T040000Z
FREEBUSY:20111024T184500Z/20111024T193000Z
FREEBUSY:20111024T220000Z/20111025T030000Z
UID:01B40176-4934-46AE-9C0A-19ECC41200E6