@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 PhabricatorProject->loadProfile

Summary: Ref T603. Do modern, sensible queries here.

Test Plan: Viewed project profile, list, member edit, profile edit, used typeahead, changed project image.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

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

+38 -25
-4
src/applications/project/controller/PhabricatorProjectMembersEditController.php
··· 26 26 if (!$project) { 27 27 return new Aphront404Response(); 28 28 } 29 - $profile = $project->loadProfile(); 30 - if (empty($profile)) { 31 - $profile = new PhabricatorProjectProfile(); 32 - } 33 29 34 30 $member_phids = $project->getMemberPHIDs(); 35 31
+5 -10
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 5 5 6 6 private $id; 7 7 private $page; 8 - private $project; 9 8 10 9 public function willProcessRequest(array $data) { 11 10 $this->id = idx($data, 'id'); ··· 16 15 $request = $this->getRequest(); 17 16 $user = $request->getUser(); 18 17 19 - $query = id(new PhabricatorProjectQuery()) 18 + $project = id(new PhabricatorProjectQuery()) 20 19 ->setViewer($user) 21 20 ->withIDs(array($this->id)) 22 - ->needMembers(true); 23 - 24 - $project = $query->executeOne(); 25 - $this->project = $project; 21 + ->needMembers(true) 22 + ->needProfiles(true) 23 + ->executeOne(); 26 24 if (!$project) { 27 25 return new Aphront404Response(); 28 26 } 29 27 30 - $profile = $project->loadProfile(); 31 - if (!$profile) { 32 - $profile = new PhabricatorProjectProfile(); 33 - } 28 + $profile = $project->getProfile(); 34 29 35 30 $picture = $profile->loadProfileImageURI(); 36 31
+2 -5
src/applications/project/controller/PhabricatorProjectProfileEditController.php
··· 22 22 PhabricatorPolicyCapability::CAN_VIEW, 23 23 PhabricatorPolicyCapability::CAN_EDIT, 24 24 )) 25 + ->needProfiles(true) 25 26 ->executeOne(); 26 27 if (!$project) { 27 28 return new Aphront404Response(); 28 29 } 29 30 30 - $profile = $project->loadProfile(); 31 - if (empty($profile)) { 32 - $profile = new PhabricatorProjectProfile(); 33 - } 34 - 31 + $profile = $project->getProfile(); 35 32 $img_src = $profile->loadProfileImageURI(); 36 33 37 34 $options = PhabricatorProjectStatus::getStatusMap();
+21
src/applications/project/query/PhabricatorProjectQuery.php
··· 16 16 const STATUS_ARCHIVED = 'status-archived'; 17 17 18 18 private $needMembers; 19 + private $needProfiles; 19 20 20 21 public function withIDs(array $ids) { 21 22 $this->ids = $ids; ··· 44 45 45 46 public function needMembers($need_members) { 46 47 $this->needMembers = $need_members; 48 + return $this; 49 + } 50 + 51 + public function needProfiles($need_profiles) { 52 + $this->needProfiles = $need_profiles; 47 53 return $this; 48 54 } 49 55 ··· 106 112 $projects[$row['id']]->setIsUserMember( 107 113 $viewer_phid, 108 114 ($row['viewerIsMember'] !== null)); 115 + } 116 + } 117 + 118 + if ($this->needProfiles) { 119 + $profiles = id(new PhabricatorProjectProfile())->loadAllWhere( 120 + 'projectPHID IN (%Ls)', 121 + mpull($projects, 'getPHID')); 122 + $profiles = mpull($profiles, null, 'getProjectPHID'); 123 + foreach ($projects as $project) { 124 + $profile = idx($profiles, $project->getPHID()); 125 + if (!$profile) { 126 + $profile = id(new PhabricatorProjectProfile()) 127 + ->setProjectPHID($project->getPHID()); 128 + } 129 + $project->attachProfile($profile); 109 130 } 110 131 } 111 132 }
+8 -5
src/applications/project/storage/PhabricatorProject.php
··· 17 17 private $subprojectsNeedUpdate; 18 18 private $memberPHIDs = self::ATTACHABLE; 19 19 private $sparseMembers = self::ATTACHABLE; 20 + private $profile = self::ATTACHABLE; 20 21 21 22 public function getCapabilities() { 22 23 return array( ··· 96 97 PhabricatorProjectPHIDTypeProject::TYPECONST); 97 98 } 98 99 99 - public function loadProfile() { 100 - $profile = id(new PhabricatorProjectProfile())->loadOneWhere( 101 - 'projectPHID = %s', 102 - $this->getPHID()); 103 - return $profile; 100 + public function getProfile() { 101 + return $this->assertAttached($this->profile); 102 + } 103 + 104 + public function attachProfile(PhabricatorProjectProfile $profile) { 105 + $this->profile = $profile; 106 + return $this; 104 107 } 105 108 106 109 public function attachMemberPHIDs(array $phids) {
+2 -1
src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php
··· 223 223 $projs = id(new PhabricatorProjectQuery()) 224 224 ->setViewer($viewer) 225 225 ->withStatus(PhabricatorProjectQuery::STATUS_OPEN) 226 + ->needProfiles(true) 226 227 ->execute(); 227 228 foreach ($projs as $proj) { 228 229 $proj_result = id(new PhabricatorTypeaheadResult()) ··· 230 231 ->setDisplayType("Project") 231 232 ->setURI('/project/view/'.$proj->getID().'/') 232 233 ->setPHID($proj->getPHID()); 233 - $prof = $proj->loadProfile(); 234 + $prof = $proj->getProfile(); 234 235 if ($prof) { 235 236 $proj_result->setImageURI($prof->loadProfileImageURI()); 236 237 }