SAAS-1121: New link show instances don't get created sometimes if there is no show content
Fixed by checking if the linked show is empty before trying to copy its tracks into new show instances
This commit is contained in:
parent
ee70a0dbea
commit
7f64edafff
|
@ -234,63 +234,65 @@ class Application_Service_SchedulerService
|
||||||
//with content from $linkedShowSchedule.
|
//with content from $linkedShowSchedule.
|
||||||
try {
|
try {
|
||||||
$con->beginTransaction();
|
$con->beginTransaction();
|
||||||
foreach ($instanceIdsToFill as $id)
|
|
||||||
{
|
|
||||||
//Start by clearing the show instance that needs to be filling. This ensure
|
|
||||||
//we're not going to get in trouble in case there's an programming error somewhere else.
|
|
||||||
self::clearShowInstanceContents($id);
|
|
||||||
|
|
||||||
// Now fill the show instance with the same content that $linkedShowSchedule has.
|
if (!empty($linkedShowSchedule)) {
|
||||||
$instanceStart_sql = "SELECT starts FROM cc_show_instances " .
|
foreach ($instanceIdsToFill as $id) {
|
||||||
"WHERE id = {$id} " . "ORDER BY starts";
|
//Start by clearing the show instance that needs to be filling. This ensure
|
||||||
|
//we're not going to get in trouble in case there's an programming error somewhere else.
|
||||||
|
self::clearShowInstanceContents($id);
|
||||||
|
|
||||||
//What's tricky here is that when we copy the content, we have to adjust
|
// Now fill the show instance with the same content that $linkedShowSchedule has.
|
||||||
//the start and end times of each track so they're inside the new show instance's time slot.
|
$instanceStart_sql = "SELECT starts FROM cc_show_instances " .
|
||||||
$nextStartDT = new DateTime(
|
"WHERE id = {$id} " . "ORDER BY starts";
|
||||||
|
|
||||||
|
//What's tricky here is that when we copy the content, we have to adjust
|
||||||
|
//the start and end times of each track so they're inside the new show instance's time slot.
|
||||||
|
$nextStartDT = new DateTime(
|
||||||
Application_Common_Database::prepareAndExecute(
|
Application_Common_Database::prepareAndExecute(
|
||||||
$instanceStart_sql, array(),
|
$instanceStart_sql, array(),
|
||||||
Application_Common_Database::COLUMN),
|
Application_Common_Database::COLUMN),
|
||||||
new DateTimeZone("UTC"));
|
new DateTimeZone("UTC"));
|
||||||
|
|
||||||
$defaultCrossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
$defaultCrossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
|
||||||
unset($values);
|
unset($values);
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($linkedShowSchedule as $item) {
|
foreach ($linkedShowSchedule as $item) {
|
||||||
$endTimeDT = self::findEndTime($nextStartDT,
|
$endTimeDT = self::findEndTime($nextStartDT,
|
||||||
$item["clip_length"]);
|
$item["clip_length"]);
|
||||||
|
|
||||||
if (is_null($item["file_id"])) {
|
if (is_null($item["file_id"])) {
|
||||||
$item["file_id"] = "null";
|
$item["file_id"] = "null";
|
||||||
}
|
}
|
||||||
if (is_null($item["stream_id"])) {
|
if (is_null($item["stream_id"])) {
|
||||||
$item["stream_id"] = "null";
|
$item["stream_id"] = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
$values[] = "(" . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
|
$values[] = "(" . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
|
||||||
"'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
|
"'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
|
||||||
"'{$item["clip_length"]}', " .
|
"'{$item["clip_length"]}', " .
|
||||||
"'{$item["fade_in"]}', " . "'{$item["fade_out"]}', " .
|
"'{$item["fade_in"]}', " . "'{$item["fade_out"]}', " .
|
||||||
"'{$item["cue_in"]}', " . "'{$item["cue_out"]}', " .
|
"'{$item["cue_in"]}', " . "'{$item["cue_out"]}', " .
|
||||||
"{$item["file_id"]}, " . "{$item["stream_id"]}, " .
|
"{$item["file_id"]}, " . "{$item["stream_id"]}, " .
|
||||||
"{$id}, " . "{$item["position"]})";
|
"{$id}, " . "{$item["position"]})";
|
||||||
|
|
||||||
$nextStartDT = self::findTimeDifference($endTimeDT,
|
$nextStartDT = self::findTimeDifference($endTimeDT,
|
||||||
$defaultCrossfadeDuration);
|
$defaultCrossfadeDuration);
|
||||||
} //foreach show item
|
} //foreach show item
|
||||||
|
|
||||||
if (!empty($values)) {
|
if (!empty($values)) {
|
||||||
$insert_sql = "INSERT INTO cc_schedule (starts, ends, ".
|
$insert_sql = "INSERT INTO cc_schedule (starts, ends, " .
|
||||||
"clip_length, fade_in, fade_out, cue_in, cue_out, ".
|
"clip_length, fade_in, fade_out, cue_in, cue_out, " .
|
||||||
"file_id, stream_id, instance_id, position) VALUES ".
|
"file_id, stream_id, instance_id, position) VALUES " .
|
||||||
implode($values, ",");
|
implode($values, ",");
|
||||||
Application_Common_Database::prepareAndExecute(
|
Application_Common_Database::prepareAndExecute(
|
||||||
$insert_sql, array(), Application_Common_Database::EXECUTE);
|
$insert_sql, array(), Application_Common_Database::EXECUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//update cc_schedule status column
|
//update cc_schedule status column
|
||||||
$instance = CcShowInstancesQuery::create()->findPk($id);
|
$instance = CcShowInstancesQuery::create()->findPk($id);
|
||||||
$instance->updateScheduleStatus($con);
|
$instance->updateScheduleStatus($con);
|
||||||
} //foreach linked instance
|
} //foreach linked instance
|
||||||
|
}
|
||||||
|
|
||||||
//update time_filled and last_scheduled in cc_show_instances
|
//update time_filled and last_scheduled in cc_show_instances
|
||||||
$now = gmdate(DEFAULT_TIMESTAMP_FORMAT);
|
$now = gmdate(DEFAULT_TIMESTAMP_FORMAT);
|
||||||
|
|
Loading…
Reference in New Issue