From be1224276ba3a87743e37b774eb897dd0adc4e94 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 4 Jun 2024 16:44:59 +0200 Subject: [PATCH] fix one problem if all recurrences of an event with explicit recurrences were overwritten/exceptions --- api/src/DateTime.php | 5 +++++ calendar/inc/class.calendar_boupdate.inc.php | 7 +++++-- calendar/inc/class.calendar_rrule.inc.php | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/api/src/DateTime.php b/api/src/DateTime.php index daaf770f95..a6059a80b5 100644 --- a/api/src/DateTime.php +++ b/api/src/DateTime.php @@ -184,6 +184,11 @@ class DateTime extends \DateTime } } + public function __toString() + { + return (string)$this->format(self::DATABASE); + } + /** * Like DateTime::add, but additional allow to use a string run through DateInterval::createFromDateString * diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index f5b20cf33b..b0ed531063 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1417,8 +1417,11 @@ class calendar_boupdate extends calendar_bo $occurrence = $rrule->current(); } while ($rrule->validDate($event['whole_day']) && ($enddate = $occurrence)); - $enddate->modify(($event['end'] - $event['start']).' second'); - $event['recur_enddate'] = $save_event['recur_enddate'] = $enddate->format('ts'); + if ($enddate) + { + $enddate->modify(($event['end'] - $event['start']).' second'); + $event['recur_enddate'] = $enddate->format('ts'); + } //error_log(__METHOD__."($event[title]) start=".Api\DateTime::to($event['start'],'string').', end='.Api\DateTime::to($event['end'],'string').', range_end='.Api\DateTime::to($event['recur_enddate'],'string')); } diff --git a/calendar/inc/class.calendar_rrule.inc.php b/calendar/inc/class.calendar_rrule.inc.php index 469679859b..e5821b08c5 100644 --- a/calendar/inc/class.calendar_rrule.inc.php +++ b/calendar/inc/class.calendar_rrule.inc.php @@ -597,9 +597,12 @@ class calendar_rrule implements Iterator { if ($this->type == self::PERIOD) { - reset($this->period); + $this->current = clone reset($this->period); + } + else + { + $this->current = clone $this->time; } - $this->current = clone $this->time; while ($this->valid() && $this->exceptions && in_array($this->current->format('Ymd'),$this->exceptions))