CC-3956: PHP script can enter inifinite loop

-small cleanup
This commit is contained in:
Martin Konecny 2012-06-12 20:18:06 -04:00
parent d1c224321b
commit 02b6d04952
1 changed files with 10 additions and 12 deletions

View File

@ -1362,27 +1362,25 @@ class Application_Model_Show {
/* pass in only the year and month (not the day) */ /* 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));
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
/* Keep adding 1 month, until we find the next month that contains the day /* Keep adding 1 month, until we find the next month that contains the day
* we are looking for (31st day for example) */ * we are looking for (31st day for example) */
do { do {
$dt->add(new DateInterval($p_interval)); $dt->add(new DateInterval($p_interval));
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y"))); } while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d")); $dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
$start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt;
} else { } else {
$dt = new DateTime($start, new DateTimeZone($timezone)); $dt = new DateTime($start, new DateTimeZone($timezone));
$dt->add(new DateInterval($p_interval)); $dt->add(new DateInterval($p_interval));
}
$start = $dt->format("Y-m-d H:i:s"); $start = $dt->format("Y-m-d H:i:s");
$dt->setTimezone(new DateTimeZone('UTC')); $dt->setTimezone(new DateTimeZone('UTC'));
$utcStartDateTime = $dt; $utcStartDateTime = $dt;
}
return array($start, $utcStartDateTime); return array($start, $utcStartDateTime);
} }