From ea949c79923dbb975b12da0dea0c7f899354e78b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 3 Sep 2013 13:06:26 +0200 Subject: [PATCH] Fix "PHP Fatal error: Call to a member function setTimezone() on a non-object" when parsing occurences of recurring events, where 'changed' date is not set (Bug #2185) --- plugins/calendar/calendar.php | 3 ++- plugins/libcalendaring/libcalendaring.php | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 5c866da7..3b8728a3 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -1205,7 +1205,8 @@ class calendar extends rcube_plugin '_id' => $event['calendar'] . ':' . $event['id'], // unique identifier for fullcalendar 'start' => $this->lib->adjust_timezone($event['start'])->format('c'), 'end' => $this->lib->adjust_timezone($event['end'])->format('c'), - 'changed' => $this->lib->adjust_timezone($event['changed'])->format('c'), + // 'changed' might be empty for event recurrences (Bug #2185) + 'changed' => $event['changed'] ? $this->lib->adjust_timezone($event['changed'])->format('c') : null, 'title' => strval($event['title']), 'description' => strval($event['description']), 'location' => strval($event['location']), diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php index 31b731da..608a5277 100644 --- a/plugins/libcalendaring/libcalendaring.php +++ b/plugins/libcalendaring/libcalendaring.php @@ -120,7 +120,10 @@ class libcalendaring extends rcube_plugin else if (is_string($dt)) $dt = new DateTime($dt); - $dt->setTimezone($this->timezone); + if ($dt instanceof DateTime) { + $dt->setTimezone($this->timezone); + } + return $dt; }