CC-3956: PHP script can enter inifinite loop

- fixed
This commit is contained in:
James 2012-06-08 17:58:21 -04:00
parent 0bae3f9038
commit 62eee61d4e
1 changed files with 41 additions and 39 deletions

View File

@ -1310,6 +1310,7 @@ class Application_Model_Show {
if ($ccShowInstance->getDbModifiedInstance()){
//show instance on this date has been deleted.
$utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone);
continue;
}
@ -1342,7 +1343,14 @@ class Application_Model_Show {
$showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
$utcStartDateTime = self::advanceRepeatingDate($p_interval, $start, $timezone);
}
Application_Model_Show::setNextPop($start, $show_id, $day);
}
private static function advanceRepeatingDate($p_interval, $start, $timezone){
if ($p_interval == 'P1M'){
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
* What ends up happening is that since February 31st doesn't exist, the date returned is
@ -1351,11 +1359,11 @@ class Application_Model_Show {
* over the years 2011->2012, etc.). Then let's append the actual day, and use the php
* checkdate() function, to see if it is valid. If not, then we'll just skip this month. */
$startDt = new DateTime($start, new DateTimeZone($timezone));
/* pass in only the year and month (not the day) */
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* Keep adding 1 month, until we find the next month that contains the day
* we are looking for (31st day for example) */
do {
@ -1375,10 +1383,7 @@ class Application_Model_Show {
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
}
}
Application_Model_Show::setNextPop($start, $show_id, $day);
return $utcStartDateTime;
}
/*
@ -1477,7 +1482,6 @@ class Application_Model_Show {
//UTC DateTime object
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
//if application is requesting shows past our previous populated until date, generate shows up until this point.
if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) {
Application_Model_Show::populateAllShowsInRange($showsPopUntil, $end_timestamp);
@ -1492,7 +1496,6 @@ class Application_Model_Show {
LEFT JOIN cc_show_instances AS si2 ON si1.instance_id = si2.id
LEFT JOIN cc_show AS show ON show.id = si1.show_id
WHERE si1.modified_instance = FALSE";
//only want shows that are starting at the time or later.
$start_string = $start_timestamp->format("Y-m-d H:i:s");
$end_string = $end_timestamp->format("Y-m-d H:i:s");
@ -1563,7 +1566,6 @@ class Application_Model_Show {
//Logging::log($sql);
$res = $con->query($sql)->fetchAll();
foreach ($res as $row) {
Application_Model_Show::populateShow($row, $p_endTimestamp);
}