From ff557ec75fa651c0234e788254dbe1dad8d7aff7 Mon Sep 17 00:00:00 2001 From: denise Date: Mon, 29 Jul 2013 15:10:24 -0400 Subject: [PATCH] CC-5283: Calendar gets messy, possibly after upgrade --- .../application/services/ShowService.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 3efe45e0f..7b817dcad 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -894,7 +894,6 @@ SQL; $utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null; - $utcStartDateTime = new DateTime("now"); $previousDate = clone $start; foreach ($datePeriod as $date) { @@ -954,12 +953,19 @@ SQL; $previousDate = clone $date; } - /* Set UTC to local time before setting the next repeat date. If we don't - * the next repeat date might be scheduled for the following day + /* We need to set the next populate date for repeat shows so when a user + * moves forward in the calendar we know when to start generating new + * show instances. + * If $utcStartDateTime is not set then we know zero new shows were + * created and we shouldn't update the next populate date. */ - $utcStartDateTime->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone())); - $nextDate = $utcStartDateTime->add($repeatInterval); - $this->setNextRepeatingShowDate($nextDate->format("Y-m-d"), $day, $show_id); + if (isset($utcStartDateTime)) { + /* Set UTC to local time before setting the next repeat date. If we don't + * the next repeat date might be scheduled for the following day */ + $utcStartDateTime->setTimezone(new DateTimeZone(Application_Model_Preference::GetTimezone())); + $nextDate = $utcStartDateTime->add($repeatInterval); + $this->setNextRepeatingShowDate($nextDate->format("Y-m-d"), $day, $show_id); + } } private function createMonthlyRepeatInstances($showDay, $populateUntil)