From 0fdb3ff5585239ff7372254a87911bb99b3258a8 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Wed, 14 Dec 2022 20:20:36 +1300 Subject: [PATCH] Add more logging to try and find the root cause for issue 268 --- inc/RRule.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/inc/RRule.php b/inc/RRule.php index 34c14e63..d69d138c 100644 --- a/inc/RRule.php +++ b/inc/RRule.php @@ -732,11 +732,26 @@ class RepeatRule { public function current($return_floating_times=false) { - if ( !$this->valid() ) return null; + if ( !$this->valid() ) { + if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', 'current: not valid at top, return null' ); + return null; + } + if ( !isset($this->instances[$this->position]) ) $this->GetMoreInstances($return_floating_times); - if ( !$this->valid() ) return null; + + if ( !isset($this->instances[$this->position]) ) { + if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', "current: \$this->instances[%s] isn't set, return null", $this->position ); + return null; + } + + if ( !$this->valid() ) { + if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', 'current: not valid after GetMoreInstances, return null' ); + return null; + } + if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', "Returning date from position %d: %s (%s)", $this->position, $this->instances[$this->position]->format('c'), $this->instances[$this->position]->FloatOrUTC($return_floating_times) ); + return $this->instances[$this->position]; } @@ -813,7 +828,7 @@ class RepeatRule { $this->current_base->modify( $this->frequency_string ); } if ( $return_floating_times ) $this->current_base->setAsFloat(); - if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', "Getting more instances from: '%s' - %d, TZ: %s", $this->current_base->format('c'), count($this->instances), $this->current_base->getTimeZone() ); + if ( DEBUG_RRULE ) dbg_error_log( 'RRULE', "Getting more instances from: '%s' - %d, TZ: %s, Loop: %s", $this->current_base->format('c'), count($this->instances), $this->current_base->getTimeZone(), $loops ); $this->current_set = array( clone($this->current_base) ); foreach( self::rrule_expand_limit($this->freq) AS $bytype => $action ) { if ( isset($this->{$bytype}) ) { @@ -1250,6 +1265,8 @@ function expand_event_instances( vComponent $vResource, $range_start = null, $ra $range_end->modify('+6 months'); } + dbg_error_log('RRULE', 'Expand event instances, start: %s, end: %s', $range_start, $range_end); + $instances = array(); $expand = false; $dtstart = null;