From b15166ecbe4424a6ba691eff8da3d11c38237ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= <tgoettgens@gmail.com> Date: Sat, 11 Jul 2020 18:48:58 +0200 Subject: [PATCH] Prevent 500 errors when no content is available --- airtime_mvc/application/controllers/ApiController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 4dd5b8c80..c9c2c82bc 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -298,19 +298,19 @@ class ApiController extends Zend_Controller_Action $stationUrl = Application_Common_HTTPHelper::getStationUrl(); - if ($result["previous"]["type"] != "livestream") { + if (($result["previous"]["type"] != "livestream") && isset($result["previous"]["metadata"])) { $previousID = $result["previous"]["metadata"]["id"]; $get_prev_artwork_url = $stationUrl . 'api/track?id='. $previousID .'&return=artwork'; $result["previous"]["metadata"]["artwork_url"] = $get_prev_artwork_url; } - if ($result["current"]["type"] != "livestream") { + if (($result["current"]["type"] != "livestream") && isset($result["current"]["metadata"])) { $currID = $result["current"]["metadata"]["id"]; $get_curr_artwork_url = $stationUrl . 'api/track?id='. $currID .'&return=artwork'; $result["current"]["metadata"]["artwork_url"] = $get_curr_artwork_url; } - if ($result["next"]["type"] != "livestream") { + if (($result["next"]["type"] != "livestream") && isset($result["next"]["metadata"])) { $nextID = $result["next"]["metadata"]["id"]; $get_next_artwork_url = $stationUrl . 'api/track?id='. $nextID .'&return=artwork'; $result["next"]["metadata"]["artwork_url"] = $get_next_artwork_url; @@ -1711,4 +1711,4 @@ class ApiController extends Zend_Controller_Action // enable cors access from configured URLs CORSHelper::enableCrossOriginRequests($request, $response); } -} \ No newline at end of file +}