From f58dce681905cad8e8ffaadba5605c83b70d7ce7 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 2 Feb 2015 13:58:33 -0800 Subject: [PATCH] Policy - remove loadRepository() method from ArcanistProjects Summary: Ref T7094. This loadRepository() method bypassed policy unnecessarily. kill it. Test Plan: basically un-tested since arcanist projects are deprecated and the main callsites were in releeph. conduit end point still works though! Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7094 Differential Revision: https://secure.phabricator.com/D11586 --- .../ArcanistProjectInfoConduitAPIMethod.php | 8 ++++++- .../ReleephBranchNamePreviewController.php | 4 +++- .../ReleephProductCreateController.php | 9 +++++++- .../product/ReleephProductEditController.php | 2 +- .../view/branch/ReleephBranchTemplate.php | 21 +++++++++++++++---- .../PhabricatorRepositoryArcanistProject.php | 8 ------- 6 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/applications/arcanist/conduit/ArcanistProjectInfoConduitAPIMethod.php b/src/applications/arcanist/conduit/ArcanistProjectInfoConduitAPIMethod.php index 5522fc7261..de47050157 100644 --- a/src/applications/arcanist/conduit/ArcanistProjectInfoConduitAPIMethod.php +++ b/src/applications/arcanist/conduit/ArcanistProjectInfoConduitAPIMethod.php @@ -38,7 +38,13 @@ final class ArcanistProjectInfoConduitAPIMethod throw new ConduitException('ERR-BAD-ARCANIST-PROJECT'); } - $repository = $project->loadRepository(); + $repository = null; + if ($project->getRepositoryID()) { + $repository = id(new PhabricatorRepositoryQuery()) + ->setViewer($request->getUser()) + ->withRepositoryIDs(array($project->getRepositoryID())) + ->executeOne(); + } $repository_phid = null; $tracked = false; diff --git a/src/applications/releeph/controller/branch/ReleephBranchNamePreviewController.php b/src/applications/releeph/controller/branch/ReleephBranchNamePreviewController.php index 8d225ea6b8..6eefc0dc83 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchNamePreviewController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchNamePreviewController.php @@ -15,7 +15,9 @@ final class ReleephBranchNamePreviewController $arc_project_id = $request->getInt('arcProjectID'); $fake_commit_handle = - ReleephBranchTemplate::getFakeCommitHandleFor($arc_project_id); + ReleephBranchTemplate::getFakeCommitHandleFor( + $arc_project_id, + $request->getUser()); list($name, $errors) = id(new ReleephBranchTemplate()) ->setCommitHandle($fake_commit_handle) diff --git a/src/applications/releeph/controller/product/ReleephProductCreateController.php b/src/applications/releeph/controller/product/ReleephProductCreateController.php index 6168c5fa1e..0bad1031b8 100644 --- a/src/applications/releeph/controller/product/ReleephProductCreateController.php +++ b/src/applications/releeph/controller/product/ReleephProductCreateController.php @@ -28,7 +28,14 @@ final class ReleephProductCreateController extends ReleephProductController { } $arc_project = $arc_projects[$arc_pr_id]; - $pr_repository = $arc_project->loadRepository(); + $pr_repository = null; + if ($arc_project->getRepositoryID()) { + $pr_repository = id(new PhabricatorRepositoryQuery()) + ->setViewer($request->getUser()) + ->withRepositoryIDs(array($arc_project->getRepositoryID())) + ->executeOne(); + } + if (!$errors) { $releeph_product = id(new ReleephProject()) diff --git a/src/applications/releeph/controller/product/ReleephProductEditController.php b/src/applications/releeph/controller/product/ReleephProductEditController.php index 34a3a48091..2399548206 100644 --- a/src/applications/releeph/controller/product/ReleephProductEditController.php +++ b/src/applications/releeph/controller/product/ReleephProductEditController.php @@ -93,7 +93,7 @@ final class ReleephProductEditController extends ReleephProductController { ->setDetail('testPaths', $test_paths); $fake_commit_handle = - ReleephBranchTemplate::getFakeCommitHandleFor($arc_project_id); + ReleephBranchTemplate::getFakeCommitHandleFor($arc_project_id, $viewer); if ($branch_template) { list($branch_name, $template_errors) = id(new ReleephBranchTemplate()) diff --git a/src/applications/releeph/view/branch/ReleephBranchTemplate.php b/src/applications/releeph/view/branch/ReleephBranchTemplate.php index 4672fc020b..73c5d5200e 100644 --- a/src/applications/releeph/view/branch/ReleephBranchTemplate.php +++ b/src/applications/releeph/view/branch/ReleephBranchTemplate.php @@ -19,7 +19,10 @@ final class ReleephBranchTemplate { return $template; } - public static function getFakeCommitHandleFor($arc_project_id) { + public static function getFakeCommitHandleFor( + $arc_project_id, + PhabricatorUser $viewer) { + $arc_project = id(new PhabricatorRepositoryArcanistProject()) ->load($arc_project_id); if (!$arc_project) { @@ -27,9 +30,19 @@ final class ReleephBranchTemplate { "No Arc project found with id '{$arc_project_id}'!"); } - $repository = $arc_project->loadRepository(); - return id(new PhabricatorObjectHandle()) - ->setName($repository->formatCommitName('100000000000')); + $repository = null; + if ($arc_project->getRepositoryID()) { + $repository = id(new PhabricatorRepositoryQuery()) + ->setViewer($viewer) + ->withRepositoryIDs(array($arc_project->getRepositoryID())) + ->executeOne(); + } + $fake_handle = 'SOFAKE'; + if ($repository) { + $fake_handle = id(new PhabricatorObjectHandle()) + ->setName($repository->formatCommitName('100000000000')); + } + return $fake_handle; } private $commitHandle; diff --git a/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php b/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php index 08a89175b0..dc18025827 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php +++ b/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php @@ -45,14 +45,6 @@ final class PhabricatorRepositoryArcanistProject PhabricatorRepositoryArcanistProjectPHIDType::TYPECONST); } - // TODO: Remove. Also, T603. - public function loadRepository() { - if (!$this->getRepositoryID()) { - return null; - } - return id(new PhabricatorRepository())->load($this->getRepositoryID()); - } - public function delete() { $this->openTransaction();