From 3b9608a8df886702181f28c951498085db0b4659 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 10 Feb 2014 16:19:26 -0500 Subject: [PATCH] CC-5693: API call to notify-item-start-playing fails because an invalid schedule id is sent Temporary fix for this bug. Throw an exception if no schedule item is found. --- airtime_mvc/application/controllers/ApiController.php | 10 +++++----- airtime_mvc/application/services/HistoryService.php | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 65306306a..d75b64b45 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -395,13 +395,13 @@ class ApiController extends Zend_Controller_Action $media_id = $this->_getParam("media_id"); Logging::debug("Received notification of new media item start: $media_id"); Application_Model_Schedule::UpdateMediaPlayedStatus($media_id); - - $historyService = new Application_Service_HistoryService(); - $historyService->insertPlayedItem($media_id); - //set a 'last played' timestamp for media item - //needed for smart blocks try { + $historyService = new Application_Service_HistoryService(); + $historyService->insertPlayedItem($media_id); + + //set a 'last played' timestamp for media item + //needed for smart blocks $mediaType = Application_Model_Schedule::GetType($media_id); if ($mediaType == 'file') { $file_id = Application_Model_Schedule::GetFileId($media_id); diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index c8ac571bc..73821ce92 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -560,6 +560,9 @@ class Application_Service_HistoryService try { $item = CcScheduleQuery::create()->findPK($schedId, $this->con); + if (is_null($item)) { + throw new Exception("Invalid schedule id: ".$schedId); + } //TODO figure out how to combine these all into 1 query. $showInstance = $item->getCcShowInstances($this->con);