Prevent crash when build step has been deleted on build plan
Summary: This prevents crashes when looking at builds, where the build steps have been deleted on the build plan since the build was run. Currently the only information that's pulled from the build step is the description (because this was too large to copy to every target). Test Plan: Tested it locally. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10361
This commit is contained in:
@@ -126,17 +126,28 @@ final class HarbormasterBuildViewController
|
||||
|
||||
$target_box->addPropertyList($properties, pht('Overview'));
|
||||
|
||||
$description = $build_target->getBuildStep()->getDescription();
|
||||
if ($description) {
|
||||
$rendered = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())
|
||||
->setContent($description)
|
||||
->setPreserveLinebreaks(true),
|
||||
'default',
|
||||
$viewer);
|
||||
$step = $build_target->getBuildStep();
|
||||
|
||||
$properties->addSectionHeader(pht('Description'));
|
||||
$properties->addTextContent($rendered);
|
||||
if ($step) {
|
||||
$description = $step->getDescription();
|
||||
if ($description) {
|
||||
$rendered = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())
|
||||
->setContent($description)
|
||||
->setPreserveLinebreaks(true),
|
||||
'default',
|
||||
$viewer);
|
||||
|
||||
$properties->addSectionHeader(pht('Description'));
|
||||
$properties->addTextContent($rendered);
|
||||
}
|
||||
} else {
|
||||
$target_box->setFormErrors(
|
||||
array(
|
||||
pht(
|
||||
'This build step has since been deleted on the build plan. '.
|
||||
'Some information may be omitted.'),
|
||||
));
|
||||
}
|
||||
|
||||
$details = $build_target->getDetails();
|
||||
|
||||
@@ -103,7 +103,7 @@ final class HarbormasterBuildTargetQuery
|
||||
|
||||
foreach ($page as $target) {
|
||||
$target->attachBuildStep(
|
||||
$steps[$target->getBuildStepPHID()]);
|
||||
idx($steps, $target->getBuildStepPHID()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ final class HarbormasterBuildTarget extends HarbormasterDAO
|
||||
return $this->assertAttached($this->build);
|
||||
}
|
||||
|
||||
public function attachBuildStep(HarbormasterBuildStep $step) {
|
||||
public function attachBuildStep(HarbormasterBuildStep $step = null) {
|
||||
$this->buildStep = $step;
|
||||
return $this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user