From dbd808745c5c6489133fcea5585b4ec57c0f8ac8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 15 Apr 2017 18:21:41 +0200 Subject: [PATCH] fix regression of #9810077: CalDAV PUT of unlimited recurring event run until max_execution_time --- calendar/inc/class.calendar_rrule.inc.php | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.calendar_rrule.inc.php b/calendar/inc/class.calendar_rrule.inc.php index 82bf0fd9f0..85cd77ad83 100644 --- a/calendar/inc/class.calendar_rrule.inc.php +++ b/calendar/inc/class.calendar_rrule.inc.php @@ -131,6 +131,24 @@ class calendar_rrule implements Iterator */ public $enddate; + /** + * Enddate of recurring event, as Ymd integer (eg. 20091111) + * + * Or 5 years in future, if no enddate. So iterator is always limited. + * + * @var int + */ + public $enddate_ymd; + + /** + * Enddate of recurring event, as timestamp + * + * Or 5 years in future, if no enddate. So iterator is always limited. + * + * @var int + */ + public $enddate_ts; + const SUNDAY = 1; const MONDAY = 2; const TUESDAY = 4; @@ -289,6 +307,8 @@ class calendar_rrule implements Iterator { $enddate->setTimezone($this->time->getTimezone()); } + $this->enddate_ymd = (int)$enddate->format('Ymd'); + $this->enddate_ts = $enddate->format('ts'); // if no valid weekdays are given for weekly repeating, we use just the current weekday if (!($this->weekdays = (int)$weekdays) && ($type == self::WEEKLY || $type == self::MONTHLY_WDAY)) @@ -535,15 +555,11 @@ class calendar_rrule implements Iterator */ public function valid($use_just_date=false) { - if (!$this->enddate) - { - return true; - } if ($use_just_date) { - return $this->current->format('Ymd') <= $this->enddate->format('Ymd'); + return $this->current->format('Ymd') <= $this->enddate_ymd; } - return $this->current->format('ts') < $this->enddate->format('ts'); + return $this->current->format('ts') < $this->enddate_ts; } /**