@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 all reads of `ReleephProject->repositoryID`

Summary:
Ref T3655. ReleephProject currently has both `repositoryID` and `repositoryPHID`, which point to the same object and are reudundant. Get rid of all reads of `repositoryID`.

NOTE: This makes project loads depend on repository loads. The eventual rule here will be that you must be able to see a repository in order to see projects for that repository, which seems like a reasonable rule. We might need to tailor it more than this (e.g., if there are branch read permissions down the line) but this seems like a reasonable minimum.

Test Plan: Grepped for `repositoryID` in `releeph/`. Called `releeph.getbranches`.

Reviewers: btrahan

Reviewed By: btrahan

CC: LegNeato, aran

Maniphest Tasks: T3655

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

+53 -20
+5 -5
src/applications/releeph/conduit/ConduitAPI_releeph_getbranches_Method.php
··· 24 24 protected function execute(ConduitAPIRequest $request) { 25 25 $results = array(); 26 26 27 - $projects = id(new ReleephProject())->loadAllWhere('isActive = 1'); 27 + $projects = id(new ReleephProjectQuery()) 28 + ->setViewer($request->getUser()) 29 + ->withActive(1) 30 + ->execute(); 28 31 29 32 foreach ($projects as $project) { 30 - $repository = $project->loadOneRelative( 31 - id(new PhabricatorRepository()), 32 - 'id', 33 - 'getRepositoryID'); 33 + $repository = $project->getRepository(); 34 34 35 35 $branches = $project->loadRelatives( 36 36 id(new ReleephBranch()),
+8 -12
src/applications/releeph/controller/project/ReleephProjectListController.php
··· 69 69 ->setHref($enable_uri)); 70 70 } 71 71 72 - // TODO: See T3551. 73 - 74 - $repo = $project->loadPhabricatorRepository(); 75 - if ($repo) { 76 - $item->addAttribute( 77 - phutil_tag( 78 - 'a', 79 - array( 80 - 'href' => '/diffusion/'.$repo->getCallsign().'/', 81 - ), 82 - 'r'.$repo->getCallsign())); 83 - } 72 + $repo = $project->getRepository(); 73 + $item->addAttribute( 74 + phutil_tag( 75 + 'a', 76 + array( 77 + 'href' => '/diffusion/'.$repo->getCallsign().'/', 78 + ), 79 + 'r'.$repo->getCallsign())); 84 80 85 81 $arc = $project->loadArcanistProject(); 86 82 if ($arc) {
+26 -1
src/applications/releeph/query/ReleephProjectQuery.php
··· 7 7 private $ids; 8 8 private $phids; 9 9 10 + private $needRepositories; 11 + 10 12 private $order = 'order-id'; 11 13 const ORDER_ID = 'order-id'; 12 14 const ORDER_NAME = 'order-name'; ··· 46 48 return $table->loadAllFromArray($rows); 47 49 } 48 50 51 + public function willFilterPage(array $projects) { 52 + assert_instances_of($projects, 'ReleephProject'); 53 + 54 + $repository_phids = mpull($projects, 'getRepositoryPHID'); 55 + 56 + $repositories = id(new PhabricatorRepositoryQuery()) 57 + ->setViewer($this->getViewer()) 58 + ->withPHIDs($repository_phids) 59 + ->execute(); 60 + $repositories = mpull($repositories, null, 'getPHID'); 61 + 62 + foreach ($projects as $key => $project) { 63 + $repo = idx($repositories, $project->getRepositoryPHID()); 64 + if (!$repo) { 65 + unset($projects[$key]); 66 + continue; 67 + } 68 + $project->attachRepository($repo); 69 + } 70 + 71 + return $projects; 72 + } 73 + 49 74 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 50 75 $where = array(); 51 76 ··· 53 78 $where[] = qsprintf( 54 79 $conn_r, 55 80 'isActive = %d', 56 - $this->active); 81 + (int)$this->active); 57 82 } 58 83 59 84 if ($this->ids) {
+14 -2
src/applications/releeph/storage/ReleephProject.php
··· 27 27 28 28 protected $details = array(); 29 29 30 + private $repository = self::ATTACHABLE; 31 + 30 32 public function getConfiguration() { 31 33 return array( 32 34 self::CONFIG_AUX_PHID => true, ··· 111 113 } 112 114 } 113 115 116 + public function attachRepository(PhabricatorRepository $repository) { 117 + $this->repository = $repository; 118 + return $this; 119 + } 120 + 121 + public function getRepository() { 122 + return $this->assertAttached($this->repository); 123 + } 124 + 125 + // TODO: Remove once everything uses ProjectQuery. 114 126 public function loadPhabricatorRepository() { 115 127 return $this->loadOneRelative( 116 128 new PhabricatorRepository(), 117 - 'id', 118 - 'getRepositoryID'); 129 + 'phid', 130 + 'getRepositoryPHID'); 119 131 } 120 132 121 133 public function getCurrentReleaseNumber() {