From 1fda844c9f5a87cf874a016869a64b45f5813ab4 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 5 Oct 2012 13:13:50 -0700 Subject: [PATCH] Avoid fatal if a macro has no file Summary: Not sure how this triggers, but we have a macro that has no file associated with it, and this caused a fatal on the /macro endpoint. Test Plan: https://phabricator.fb.com/macro/?page=100 Reviewers: vrana, nh, epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D3642 --- .../PhabricatorMacroListController.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/applications/macro/controller/PhabricatorMacroListController.php b/src/applications/macro/controller/PhabricatorMacroListController.php index 3cb522f227..09fde89bab 100644 --- a/src/applications/macro/controller/PhabricatorMacroListController.php +++ b/src/applications/macro/controller/PhabricatorMacroListController.php @@ -91,7 +91,6 @@ final class PhabricatorMacroListController $nav->appendChild($filter_view); - if ($macros) { $pinboard = new PhabricatorPinboardView(); foreach ($macros as $macro) { @@ -99,24 +98,25 @@ final class PhabricatorMacroListController $file = idx($files_map, $file_phid); $item = new PhabricatorPinboardItemView(); - $item->setImageURI($file->getThumb160x120URI()); - $item->setImageSize(160, 120); + if ($file) { + $item->setImageURI($file->getThumb160x120URI()); + $item->setImageSize(160, 120); + if ($file->getAuthorPHID()) { + $author_handle = $this->getHandle($file->getAuthorPHID()); + $item->appendChild( + 'Created by '.$author_handle->renderLink()); + } + $datetime = phabricator_date($file->getDateCreated(), $viewer); + $item->appendChild( + phutil_render_tag( + 'div', + array(), + 'Created on '.$datetime)); + + } $item->setURI($this->getApplicationURI('/edit/'.$macro->getID().'/')); $item->setHeader($macro->getName()); - if ($file->getAuthorPHID()) { - $author_handle = $this->getHandle($file->getAuthorPHID()); - $item->appendChild( - 'Created by '.$author_handle->renderLink()); - } - - $datetime = phabricator_date($file->getDateCreated(), $viewer); - $item->appendChild( - phutil_render_tag( - 'div', - array(), - 'Created on '.$datetime)); - $pinboard->addItem($item); } $nav->appendChild($pinboard);