diff --git a/src/applications/conduit/method/project/ConduitAPI_project_Method.php b/src/applications/conduit/method/project/ConduitAPI_project_Method.php
index a5762bcaa7..96bdc7f921 100644
--- a/src/applications/conduit/method/project/ConduitAPI_project_Method.php
+++ b/src/applications/conduit/method/project/ConduitAPI_project_Method.php
@@ -35,7 +35,7 @@ abstract class ConduitAPI_project_Method extends ConduitAPIMethod {
$result = array();
foreach ($projects as $project) {
- $member_phids = mpull($project->getAffiliations(), 'getUserPHID');
+ $member_phids = $project->getMemberPHIDs();
$member_phids = array_values($member_phids);
$result[$project->getPHID()] = array(
diff --git a/src/applications/project/controller/PhabricatorProjectProfileController.php b/src/applications/project/controller/PhabricatorProjectProfileController.php
index 5f781a5609..9bdcd97a72 100644
--- a/src/applications/project/controller/PhabricatorProjectProfileController.php
+++ b/src/applications/project/controller/PhabricatorProjectProfileController.php
@@ -41,8 +41,8 @@ final class PhabricatorProjectProfileController
}
$picture = $profile->loadProfileImageURI();
-
- $members = mpull($project->loadAffiliations(), null, 'getUserPHID');
+ $members = $project->loadMemberPHIDs();
+ $member_map = array_fill_keys($members, true);
$nav_view = new AphrontSideNavFilterView();
$uri = new PhutilURI('/project/view/'.$project->getID().'/');
@@ -107,7 +107,7 @@ final class PhabricatorProjectProfileController
$header->setProfilePicture($picture);
$action = null;
- if (empty($members[$user->getPHID()])) {
+ if (empty($member_map[$user->getPHID()])) {
$action = phabricator_render_form(
$user,
array(
@@ -211,17 +211,13 @@ final class PhabricatorProjectProfileController
PhabricatorProject $project,
PhabricatorProjectProfile $profile) {
- $affiliations = $project->loadAffiliations();
-
- $phids = mpull($affiliations, 'getUserPHID');
- $handles = id(new PhabricatorObjectHandleData($phids))
+ $member_phids = $project->loadMemberPHIDs();
+ $handles = id(new PhabricatorObjectHandleData($member_phids))
->loadHandles();
$affiliated = array();
- foreach ($affiliations as $affiliation) {
- $user = $handles[$affiliation->getUserPHID()]->renderLink();
- $role = phutil_escape_html($affiliation->getRole());
- $affiliated[] = '
'.$user.' — '.$role.'';
+ foreach ($handles as $phids => $handle) {
+ $affiliated[] = ''.$handle->renderLink().'';
}
if ($affiliated) {
diff --git a/src/applications/project/controller/PhabricatorProjectUpdateController.php b/src/applications/project/controller/PhabricatorProjectUpdateController.php
index 29e589042c..32adf77bc8 100644
--- a/src/applications/project/controller/PhabricatorProjectUpdateController.php
+++ b/src/applications/project/controller/PhabricatorProjectUpdateController.php
@@ -53,30 +53,31 @@ final class PhabricatorProjectUpdateController
if ($process_action) {
$xactions = array();
+
switch ($this->action) {
case 'join':
- $affils = $project->loadAffiliations();
- $affils = mpull($affils, null, 'getUserPHID');
- if (empty($affils[$user->getPHID()])) {
- $affils[$user->getPHID()] = true;
+ $member_phids = $project->loadMemberPHIDs();
+ $member_map = array_fill_keys($member_phids, true);
+ if (empty($member_map[$user->getPHID()])) {
+ $member_map[$user->getPHID()] = true;
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_MEMBERS);
- $xaction->setNewValue(array_keys($affils));
+ $xaction->setNewValue(array_keys($member_map));
$xactions[] = $xaction;
}
break;
case 'leave':
- $affils = $project->loadAffiliations();
- $affils = mpull($affils, null, 'getUserPHID');
- if (isset($affils[$user->getPHID()])) {
- unset($affils[$user->getPHID()]);
+ $member_phids = $project->loadMemberPHIDs();
+ $member_map = array_fill_keys($member_phids, true);
+ if (isset($member_map[$user->getPHID()])) {
+ unset($member_map[$user->getPHID()]);
$xaction = new PhabricatorProjectTransaction();
$xaction->setTransactionType(
PhabricatorProjectTransactionType::TYPE_MEMBERS);
- $xaction->setNewValue(array_keys($affils));
+ $xaction->setNewValue(array_keys($member_map));
$xactions[] = $xaction;
}
break;
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
index c279d0a953..47a44ccc4b 100644
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -55,6 +55,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO {
return $profile;
}
+ public function getMemberPHIDs() {
+ return mpull($this->getAffiliations(), 'getUserPHID');
+ }
+
+ public function loadMemberPHIDs() {
+ return mpull($this->loadAffiliations(), 'getUserPHID');
+ }
+
public function getAffiliations() {
if ($this->affiliations === null) {
throw new Exception('Attach affiliations first!');