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

Fix a fatal on the file info screen

Summary: D1354 added a query for a possibly-empty list -- only show the table if
there are transformations.

Test Plan: Reloaded a previously-fataling page, no fatals. Viewed a file with
transformations, got a list.

Reviewers: davidreuss, btrahan, jungejason

Reviewed By: davidreuss

CC: aran, davidreuss

Differential Revision: https://secure.phabricator.com/D1414
This commit is contained in:
epriestley 2012-01-16 06:54:08 -08:00
parent 49a59bd885
commit 025cc1376e

View file

@ -180,40 +180,44 @@ class PhabricatorFileViewController extends PhabricatorFileController {
$panel->appendChild($form); $panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM); $panel->setWidth(AphrontPanelView::WIDTH_FORM);
$xform_panel = null;
$transformations = id(new PhabricatorTransformedFile())->loadAllWhere( $transformations = id(new PhabricatorTransformedFile())->loadAllWhere(
'originalPHID = %s', 'originalPHID = %s',
$file->getPHID()); $file->getPHID());
$transformed_phids = mpull($transformations, 'getTransformedPHID'); if ($transformations) {
$transformed_files = id(new PhabricatorFile())->loadAllWhere( $transformed_phids = mpull($transformations, 'getTransformedPHID');
'phid in (%Ls)', $transformed_files = id(new PhabricatorFile())->loadAllWhere(
$transformed_phids); 'phid in (%Ls)',
$transformed_map = mpull($transformed_files, null, 'getPHID'); $transformed_phids);
$rows = array(); $transformed_map = mpull($transformed_files, null, 'getPHID');
foreach ($transformations as $transformed) {
$phid = $transformed->getTransformedPHID(); $rows = array();
$rows[] = array( foreach ($transformations as $transformed) {
phutil_escape_html($transformed->getTransform()), $phid = $transformed->getTransformedPHID();
phutil_render_tag( $rows[] = array(
'a', phutil_escape_html($transformed->getTransform()),
array( phutil_render_tag(
'href' => $transformed_map[$phid]->getBestURI(), 'a',
), array(
$phid)); 'href' => $transformed_map[$phid]->getBestURI(),
),
$phid));
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Transform',
'File',
));
$xform_panel = new AphrontPanelView();
$xform_panel->appendChild($table);
$xform_panel->setWidth(AphrontPanelView::WIDTH_FORM);
$xform_panel->setHeader('Transformations');
} }
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Transform',
'File',
));
$xform_panel = new AphrontPanelView();
$xform_panel->appendChild($table);
$xform_panel->setWidth(AphrontPanelView::WIDTH_FORM);
$xform_panel->setHeader('Transformations');
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
array($panel, $xform_panel), array($panel, $xform_panel),
array( array(