From d93a5196b858e31d42d9ade3c4838036df65637c Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Wed, 14 Dec 2022 20:22:49 +1300 Subject: [PATCH] Increase loop limit for finding next instance for Recurrence Rules. With complex rules, it make take more than 10 expansions to find the next valid date. Increase this to 100, it doesn't slow things down too much. I've also added some additional error logging if this issue occurs again. Closes #268. --- inc/RRule.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/RRule.php b/inc/RRule.php index d69d138c..eb982143 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -817,10 +817,15 @@ class RepeatRule { private function GetMoreInstances($return_floating_times=false) { if ( $this->finished ) return; $got_more = false; - $loop_limit = 10; + $loop_limit = 100; $loops = 0; if ( $return_floating_times ) $this->base->setAsFloat(); - while( !$this->finished && !$got_more && $loops++ < $loop_limit ) { + while( !$this->finished && !$got_more) { + if ($loops++ > $loop_limit ) { + dbg_error_log ('ERROR', "RRULE, loop limit has been hit in GetMoreInstances, this probably needs to be increased (loop_limit: %d)", $loop_limit); + break; + } + if ( !isset($this->current_base) ) { $this->current_base = clone($this->base); }