@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

Don't fatal when viewing tags pointing at commits we haven't imported/parsed yet

Summary:
In Diffusion, the "Tags" view may read commits which haven't imported or parsed yet, and thus don't have loadable objects.

Most of this logic tests for `if ($commit)`, but the author part did not. Instead, don't render author information if `$commit` is not present.

Test Plan:
- Loaded tags view with commits present.
- Faked `$commit = null;`, loaded tag view, got this instead of a fatal:

{F5068432}

Reviewers: chad, amckinley

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D18290

+31 -16
+31 -16
src/applications/diffusion/view/DiffusionTagListView.php
··· 52 52 'commit' => $tag->getCommitIdentifier(), 53 53 )); 54 54 55 - $author = null; 56 - if ($commit && $commit->getAuthorPHID()) { 57 - $author = $this->handles[$commit->getAuthorPHID()]->renderLink(); 58 - } else if ($commit && $commit->getCommitData()) { 59 - $author = self::renderName($commit->getCommitData()->getAuthorName()); 55 + if ($commit) { 56 + $author = $this->renderAuthor($tag, $commit); 60 57 } else { 61 - $author = self::renderName($tag->getAuthor()); 58 + $author = null; 62 59 } 63 - 64 - $committed = phabricator_datetime($commit->getEpoch(), $viewer); 65 - $author_name = phutil_tag( 66 - 'strong', 67 - array( 68 - 'class' => 'diffusion-history-author-name', 69 - ), 70 - $author); 71 - $authored = pht('%s on %s.', $author_name, $committed); 72 60 73 61 $description = null; 74 62 if ($tag->getType() == 'git/tag') { ··· 139 127 ->setHref($tag_href) 140 128 ->addAttribute(array($commit_tag)) 141 129 ->addAttribute($description) 142 - ->addAttribute($authored) 143 130 ->setSideColumn(array( 144 131 $build_view, 145 132 $button_bar, 146 133 )); 147 134 135 + if ($author) { 136 + $item->addAttribute($author); 137 + } 138 + 148 139 $list->addItem($item); 149 140 } 150 141 151 142 return $list; 143 + } 144 + 145 + private function renderAuthor( 146 + DiffusionRepositoryTag $tag, 147 + PhabricatorRepositoryCommit $commit) { 148 + $viewer = $this->getViewer(); 149 + 150 + if ($commit->getAuthorPHID()) { 151 + $author = $this->handles[$commit->getAuthorPHID()]->renderLink(); 152 + } else if ($commit->getCommitData()) { 153 + $author = self::renderName($commit->getCommitData()->getAuthorName()); 154 + } else { 155 + $author = self::renderName($tag->getAuthor()); 156 + } 157 + 158 + $committed = phabricator_datetime($commit->getEpoch(), $viewer); 159 + $author_name = phutil_tag( 160 + 'strong', 161 + array( 162 + 'class' => 'diffusion-history-author-name', 163 + ), 164 + $author); 165 + 166 + return pht('%s on %s.', $author_name, $committed); 152 167 } 153 168 154 169 }