From 4e047f7b31d2734a0e69c1bb7333941217361f71 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 30 Jun 2017 06:56:10 -0700 Subject: [PATCH] Correct a datasource issue when viewing repository URIs in "Manage Repository" Summary: Fixes T12884. In cases other than this UI, applications access URIs through the Repository they're part of. This means that applications interact with URIs which have gone through the correction/adjustment logic in `PhabricatorRepository->attachURIs()`, which fixes up "builtin" URIs to have the right values based on configuration. In this case (and, as far as I can tell, only this case) we load the URI directly //and// act on its properties which depend on configuration and repository state. This can mean we're using a different view of the URI than we should be. To fix this: after loading the URI, reload it through the repository so the relevant adjustments are applied. I think this is the most reasonable fix. We could try to make `RepositoryURIQuery` somehow enforce this, but the cost of this error is small (mild confusion about display state), the other things which do direct loads don't depend on this state (editing), and everything else loads via a repository and is likely to continue doing that forever. Test Plan: {F5026633} Reviewers: chad, amckinley Reviewed By: chad Maniphest Tasks: T12884 Differential Revision: https://secure.phabricator.com/D18176 --- .../DiffusionRepositoryURIViewController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php index 61335d20d0..308df8f0d2 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryURIViewController.php @@ -23,6 +23,22 @@ final class DiffusionRepositoryURIViewController return new Aphront404Response(); } + // For display, reload the URI by loading it through the repository. This + // may adjust builtin URIs for repository configuration, so we may end up + // with a different view of builtin URIs than we'd see if we loaded them + // directly from the database. See T12884. + $repository_with_uris = id(new PhabricatorRepositoryQuery()) + ->setViewer($viewer) + ->needURIs(true) + ->execute(); + + $repository_uris = $repository->getURIs(); + $repository_uris = mpull($repository_uris, null, 'getID'); + $uri = idx($repository_uris, $uri->getID()); + if (!$uri) { + return new Aphront404Response(); + } + $title = array( pht('URI'), $repository->getDisplayName(),