From c77749a0966975b51b312ab97a6251c840cb2cd4 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 9 Sep 2015 18:59:00 -0400 Subject: [PATCH] SAAS: Show logo is deleted on disk when a show instance is deleted * Default to returning the station logo in response if we can't find the show logo on disk (but it's in our DB). --- .../application/controllers/ApiController.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index cf1241e1e..d30013d8d 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -416,17 +416,26 @@ class ApiController extends Zend_Controller_Action } $path = $show->getDbImagePath(); - $mime_type = mime_content_type($path); - if (empty($path)) { - throw new ZendActionHttpException($this, 400, "ERROR: Show does not have an associated image."); + try { + $mime_type = mime_content_type($path); + if (empty($path)) { + throw new ZendActionHttpException($this, 400, "ERROR: Show does not have an associated image."); + } + } catch (Exception $e) { + //To avoid broken images on your site, we return the station logo if we can't find the show logo. + $this->_redirect('api/station-logo'); + return; } + try { // Sometimes end users may be looking at stale data - if an image is removed // but has been cached in a client's browser this will throw an exception Application_Common_FileIO::smartReadFile($path, filesize($path), $mime_type); } catch(FileNotFoundException $e) { - throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path"); + //throw new ZendActionHttpException($this, 404, "ERROR: No image found at $path"); + $this->_redirect('api/station-logo'); + return; } catch(Exception $e) { throw new ZendActionHttpException($this, 500, "ERROR: " . $e->getMessage()); }