@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix an issue where Diffusion could fatal if the default branch was deleted

Summary: See PHI234. In T12931 we improved the behavior of Diffusion when a repository's default branch is set to a branch that does not exist, but in T11823 the way refcursors work changed, and we can now get a cursor (just with no positions) back for a deleted branch. When we did, we didn't handle things gracefully.

Test Plan:
- Set default branch to a deleted branch, saw nice error instead of fatal.
- Set default branch to a nonexistent branch which never existed, saw nice error.
- Set default branch to existing "master", saw repository normally.

Reviewers: amckinley

Reviewed By: amckinley

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

+13 -1
+13 -1
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 46 46 ->withRepositoryPHIDs(array($repository->getPHID())) 47 47 ->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH)) 48 48 ->withRefNames(array($drequest->getBranch())) 49 + ->needPositions(true) 49 50 ->execute(); 50 - if ($ref_cursors) { 51 + 52 + // It's possible that this branch previously existed, but has been 53 + // deleted. Make sure we have valid cursor positions, not just cursors. 54 + $any_positions = false; 55 + foreach ($ref_cursors as $ref_cursor) { 56 + if ($ref_cursor->getPositions()) { 57 + $any_positions = true; 58 + break; 59 + } 60 + } 61 + 62 + if ($any_positions) { 51 63 // This is a valid branch, so we necessarily have some content. 52 64 $page_has_content = true; 53 65 } else {