diff --git a/calendar.php b/calendar.php index 5debec6..232c10f 100644 --- a/calendar.php +++ b/calendar.php @@ -3180,6 +3180,19 @@ public function itip_event_inviteform($attrib) ) . $hidden->show(); } + /** + * Escape DateTimeImmutableObject to DateTime if necessary + */ + private function sanitize_date_time_immutable($date) + { + $dateclone = clone $date; + if (is_object($dateclone) && is_a($dateclone, 'DateTimeImmutable')) { + return DateTime::createFromImmutable($dateclone); + } else { + return $dateclone; + } + } + /** * */ @@ -3189,8 +3202,8 @@ private function mail_agenda_event_row($event, $class = '') $time = $this->gettext('all-day'); } else { - $start = is_object($event['start']) ? clone $event['start'] : $event['start']; - $end = is_object($event['end']) ? clone $event['end'] : $event['end']; + $start = is_object($event['start']) ? $this->sanitize_date_time_immutable($event['start']) : $event['start']; + $end = is_object($event['end']) ? $this->sanitize_date_time_immutable($event['end']) : $event['end']; $time = $this->rc->format_date($start, $this->rc->config->get('time_format')) . ' - ' . $this->rc->format_date($end, $this->rc->config->get('time_format')); @@ -3259,7 +3272,7 @@ public function mail_messagebody_html($p) // get prepared inline UI for this event object if ($ical_objects->method) { $append = ''; - $date_str = $this->rc->format_date(clone $event['start'], $this->rc->config->get('date_format'), empty($event['start']->_dateonly)); + $date_str = $this->rc->format_date($this->sanitize_date_time_immutable($event['start']), $this->rc->config->get('date_format'), empty($event['start']->_dateonly)); $date = new DateTime($event['start']->format('Y-m-d') . ' 12:00:00', new DateTimeZone('UTC')); // prepare a small agenda preview to be filled with actual event data on async request