CC-5589: SQL error when adding/moving a scheduled item

Error was occuring when a moved item didn't exist in a linked show instance
Error was also occuring when trying to insert item into a schedule localtion
that does not exist in a linked instance.

Fixed by skipping the move action if the file does not exist in a linked instance,
cleaning up the position numbers after deleting schedule items, and by
setting the insert time to the show start time in a linked instance is empty
This commit is contained in:
drigato 2013-12-02 16:40:15 -05:00
parent 81912f2934
commit eae93008b4
2 changed files with 55 additions and 11 deletions

View file

@ -138,6 +138,29 @@ class CcShowInstances extends BaseCcShowInstances {
$this->setDbLastScheduled(gmdate("Y-m-d H:i:s"));
$this->save($con);
}
/**
*
* This function resets the cc_schedule table's position numbers so that
* tracks for each cc_show_instances start at position 1
*
* The position numbers can become out of sync when the user deletes items
* from linekd shows filled with dyanmic smart blocks, where each instance
* has a different amount of scheduled items
*/
public function correctSchedulePositions()
{
$schedule = CcScheduleQuery::create()
->filterByDbInstanceId($this->id)
->orderByDbStarts()
->find();
$pos = 0;
foreach ($schedule as $item) {
$item->setDbPosition($pos)->save();
$pos++;
}
}
/**
* Computes the value of the aggregate column time_filled