Page MenuHomePhabricator

People profile display error when prototypes are disabled
Closed, ResolvedPublic

Description

Description

Trying to display someones profile when using show-prototypes = false display the following error:

Undefined Variable: flex

This bug seems introduced by @chad in commit 2f0571923c9ae5a2b6cbfb49b25c7776a2d64041

private function buildBadgesView(
  PhabricatorUser $user) {

  $viewer = $this->getViewer();
  $class = 'PhabricatorBadgesApplication';

  if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
    $badge_phids = $user->getBadgePHIDs();
    if ($badge_phids) {
      $badges = id(new PhabricatorBadgesQuery())
        ->setViewer($viewer)
        ->withPHIDs($badge_phids)
        ->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
        ->execute();

      $flex = new PHUIBadgeBoxView();
      foreach ($badges as $badge) {
        $item = id(new PHUIBadgeView())
          ->setIcon($badge->getIcon())
          ->setHeader($badge->getName())
          ->setSubhead($badge->getFlavor())
          ->setQuality($badge->getQuality());
        $flex->addItem($item);
      }

    } else {
      $error = id(new PHUIBoxView())
        ->addClass('mlb')
        ->appendChild(pht('User does not have any badges.'));
      $flex = id(new PHUIInfoView())
        ->setSeverity(PHUIInfoView::SEVERITY_NODATA)
        ->appendChild($error);
    }
  }

  $box = id(new PHUIObjectBoxView())
    ->setHeaderText(pht('Badges'))
    ->appendChild($flex)
    ->setBackground(PHUIBoxView::GREY);

  return $box;
}

The last block of code seems to be the cullprit and should be in the if PhabricatorApplicationsection scope.