mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-28 12:08:14 +01:00
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
This commit is contained in:
parent
14cc0abeb3
commit
5240cffd9c
1 changed files with 13 additions and 1 deletions
|
@ -46,8 +46,20 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
->withRepositoryPHIDs(array($repository->getPHID()))
|
||||
->withRefTypes(array(PhabricatorRepositoryRefCursor::TYPE_BRANCH))
|
||||
->withRefNames(array($drequest->getBranch()))
|
||||
->needPositions(true)
|
||||
->execute();
|
||||
if ($ref_cursors) {
|
||||
|
||||
// It's possible that this branch previously existed, but has been
|
||||
// deleted. Make sure we have valid cursor positions, not just cursors.
|
||||
$any_positions = false;
|
||||
foreach ($ref_cursors as $ref_cursor) {
|
||||
if ($ref_cursor->getPositions()) {
|
||||
$any_positions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($any_positions) {
|
||||
// This is a valid branch, so we necessarily have some content.
|
||||
$page_has_content = true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue