1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 21:40:55 +01:00

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
This commit is contained in:
Wez Furlong 2012-10-05 13:13:50 -07:00
parent 7c0f0807da
commit 1fda844c9f

View file

@ -91,7 +91,6 @@ final class PhabricatorMacroListController
$nav->appendChild($filter_view); $nav->appendChild($filter_view);
if ($macros) { if ($macros) {
$pinboard = new PhabricatorPinboardView(); $pinboard = new PhabricatorPinboardView();
foreach ($macros as $macro) { foreach ($macros as $macro) {
@ -99,24 +98,25 @@ final class PhabricatorMacroListController
$file = idx($files_map, $file_phid); $file = idx($files_map, $file_phid);
$item = new PhabricatorPinboardItemView(); $item = new PhabricatorPinboardItemView();
$item->setImageURI($file->getThumb160x120URI()); if ($file) {
$item->setImageSize(160, 120); $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->setURI($this->getApplicationURI('/edit/'.$macro->getID().'/'));
$item->setHeader($macro->getName()); $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); $pinboard->addItem($item);
} }
$nav->appendChild($pinboard); $nav->appendChild($pinboard);