@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.

Remove several "loadArcanistProject()" methods

Summary:
Ref T3551. Releeph has old-style `loadX()` methods; get rid of one of them.

Differential has a couple of copies of this too, clean them up.

Test Plan:
- Viewed various differential revisions (with and without projects).
- Viewed and edited Releeph products.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3551

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

+57 -31
+14 -2
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 33 33 $diffs = id(new DifferentialDiffQuery()) 34 34 ->setViewer($request->getUser()) 35 35 ->withRevisionIDs(array($this->revisionID)) 36 + ->needArcanistProjects(true) 36 37 ->execute(); 37 38 $diffs = array_reverse($diffs, $preserve_keys = true); 38 39 ··· 61 62 $diff_vs = null; 62 63 } 63 64 64 - $arc_project = $target->loadArcanistProject(); 65 - $repository = ($arc_project ? $arc_project->loadRepository() : null); 65 + $repository = null; 66 + $repository_phid = $target->getRepositoryPHID(); 67 + if ($repository_phid) { 68 + if ($repository_phid == $revision->getRepositoryPHID()) { 69 + $repository = $revision->getRepository(); 70 + } else { 71 + $repository = id(new PhabricatorRepositoryQuery()) 72 + ->setViewer($user) 73 + ->withPHIDs(array($repository_phid)) 74 + ->executeOne(); 75 + } 76 + } 66 77 67 78 list($changesets, $vs_map, $vs_changesets, $rendering_references) = 68 79 $this->loadChangesetsAndVsMap( ··· 219 230 'whitespace', 220 231 DifferentialChangesetParser::WHITESPACE_IGNORE_ALL); 221 232 233 + $arc_project = $target->getArcanistProject(); 222 234 if ($arc_project) { 223 235 list($symbol_indexes, $project_phids) = $this->buildSymbolIndexes( 224 236 $arc_project,
-21
src/applications/differential/storage/DifferentialDiff.php
··· 95 95 return $name; 96 96 } 97 97 98 - public function loadArcanistProject() { 99 - if (!$this->getArcanistProjectPHID()) { 100 - return null; 101 - } 102 - return id(new PhabricatorRepositoryArcanistProject())->loadOneWhere( 103 - 'phid = %s', 104 - $this->getArcanistProjectPHID()); 105 - } 106 - 107 - public function getBackingVersionControlSystem() { 108 - $arcanist_project = $this->loadArcanistProject(); 109 - if (!$arcanist_project) { 110 - return null; 111 - } 112 - $repository = $arcanist_project->loadRepository(); 113 - if (!$repository) { 114 - return null; 115 - } 116 - return $repository->getVersionControlSystem(); 117 - } 118 - 119 98 public function save() { 120 99 $this->openTransaction(); 121 100 $ret = parent::save();
+2 -1
src/applications/releeph/controller/project/ReleephProductEditController.php
··· 15 15 $product = id(new ReleephProjectQuery()) 16 16 ->setViewer($viewer) 17 17 ->withIDs(array($this->productID)) 18 + ->needArcanistProjects(true) 18 19 ->requireCapabilities( 19 20 array( 20 21 PhabricatorPolicyCapability::CAN_VIEW, ··· 145 146 id(new AphrontFormStaticControl()) 146 147 ->setLabel(pht('Arc Project')) 147 148 ->setValue( 148 - $product->loadArcanistProject()->getName())) 149 + $product->getArcanistProject()->getName())) 149 150 ->appendChild( 150 151 id(new AphrontFormStaticControl()) 151 152 ->setLabel(pht('Releeph Project PHID'))
+1 -1
src/applications/releeph/controller/project/ReleephProductListController.php
··· 53 53 ), 54 54 'r'.$repo->getCallsign())); 55 55 56 - $arc = $product->loadArcanistProject(); 56 + $arc = $product->getArcanistProject(); 57 57 if ($arc) { 58 58 $item->addAttribute($arc->getName()); 59 59 }
+2 -1
src/applications/releeph/query/ReleephProductSearchEngine.php
··· 13 13 14 14 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 15 15 $query = id(new ReleephProjectQuery()) 16 - ->setOrder(ReleephProjectQuery::ORDER_NAME); 16 + ->setOrder(ReleephProjectQuery::ORDER_NAME) 17 + ->needArcanistProjects(true); 17 18 18 19 $active = $saved->getParameter('active'); 19 20 $value = idx($this->getActiveValues(), $active);
+29
src/applications/releeph/query/ReleephProjectQuery.php
··· 8 8 private $phids; 9 9 10 10 private $needRepositories; 11 + private $needArcanistProjects; 11 12 12 13 private $order = 'order-id'; 13 14 const ORDER_ID = 'order-id'; ··· 30 31 31 32 public function withPHIDs(array $phids) { 32 33 $this->phids = $phids; 34 + return $this; 35 + } 36 + 37 + public function needArcanistProjects($need) { 38 + $this->needArcanistProjects = $need; 33 39 return $this; 34 40 } 35 41 ··· 70 76 71 77 return $projects; 72 78 } 79 + 80 + public function didFilterPage(array $products) { 81 + 82 + if ($this->needArcanistProjects) { 83 + $project_ids = array_filter(mpull($products, 'getArcanistProjectID')); 84 + if ($project_ids) { 85 + $projects = id(new PhabricatorRepositoryArcanistProject()) 86 + ->loadAllWhere('id IN (%Ld)', $project_ids); 87 + $projects = mpull($projects, null, 'getID'); 88 + } else { 89 + $projects = array(); 90 + } 91 + 92 + foreach ($products as $product) { 93 + $project_id = $product->getArcanistProjectID(); 94 + $project = idx($projects, $project_id); 95 + $product->attachArcanistProject($project); 96 + } 97 + } 98 + 99 + return $products; 100 + } 101 + 73 102 74 103 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 75 104 $where = array();
+9 -5
src/applications/releeph/storage/ReleephProject.php
··· 21 21 protected $details = array(); 22 22 23 23 private $repository = self::ATTACHABLE; 24 + private $arcanistProject = self::ATTACHABLE; 24 25 25 26 public function getConfiguration() { 26 27 return array( ··· 53 54 return $this; 54 55 } 55 56 56 - public function loadArcanistProject() { 57 - return $this->loadOneRelative( 58 - new PhabricatorRepositoryArcanistProject(), 59 - 'id', 60 - 'getArcanistProjectID'); 57 + public function getArcanistProject() { 58 + return $this->assertAttached($this->arcanistProject); 59 + } 60 + 61 + public function attachArcanistProject( 62 + PhabricatorRepositoryArcanistProject $arcanist_project = null) { 63 + $this->arcanistProject = $arcanist_project; 64 + return $this; 61 65 } 62 66 63 67 public function getPushers() {