From 99c6b53ab2248e5d94a9589398df437a106c9744 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 1 Dec 2016 14:20:53 -0800 Subject: [PATCH] Explicitly update the repository URI index after making a URI edit Summary: Fixes T11936. After editing a repository URI, we were not correctly updating the URI index. Any other edit to the repository //would// update the index, and this index is only really used by `arc` to figure out which repository a working copy belongs to, so that's how this evaded detection for this long. In particular, creating a repository would usually have an edit after any URI edits, to activate it, which would build the index correctly. Test Plan: - Added a new URI to a repository. - Verified it was immediately reflected in the `repository_uriindex` table. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11936 Differential Revision: https://secure.phabricator.com/D16972 --- src/applications/diffusion/editor/DiffusionURIEditor.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/applications/diffusion/editor/DiffusionURIEditor.php b/src/applications/diffusion/editor/DiffusionURIEditor.php index b8eabb9ef1..9219935d3a 100644 --- a/src/applications/diffusion/editor/DiffusionURIEditor.php +++ b/src/applications/diffusion/editor/DiffusionURIEditor.php @@ -462,6 +462,11 @@ final class DiffusionURIEditor ->withRepositories(array($repository)) ->execute(); + // Reattach the current URIs to the repository: we're going to rebuild + // the index explicitly below, and want to include any changes made to + // this URI in the index update. + $repository->attachURIs($uris); + $observe_uri = null; foreach ($uris as $uri) { if ($uri->getIoType() != PhabricatorRepositoryURI::IO_OBSERVE) { @@ -488,6 +493,9 @@ final class DiffusionURIEditor $repository->save(); + // Explicitly update the URI index. + $repository->updateURIIndex(); + $is_hosted = $repository->isHosted(); // If we've swapped the repository from hosted to observed or vice versa,