1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Fix expansion of projects into lists of user PHIDs

Summary:
Ref T11016. I think I inverted the meaning of this function by accident in D14893.

The intent is to return a list of users: direct users, and all members of all projects.

Prior to this patch actually returns direct users, and all projects they are members of.

Test Plan:
  - Created "Project with Dog".
  - Added user "dog" to project.
  - Created package "X", owning file "/x", with audit enabled.
  - Made "X" owned by "Project with Dog".
  - Modified "/x" and had user "dog" accept it.
  - Landed change.
  - Prior to change: package "X" incorrectly added as auditor.
  - After change: package "X" correctly omitted as auditor, because a member reviewed the change.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11016

Differential Revision: https://secure.phabricator.com/D15971
This commit is contained in:
epriestley 2016-05-24 06:05:22 -07:00
parent 74e117ae41
commit d1eed54d85

View file

@ -45,25 +45,37 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO {
'packageID IN (%Ls)',
$package_ids);
$all_phids = phid_group_by_type(mpull($owners, 'getUserPHID'));
$type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
$user_phids = idx($all_phids,
PhabricatorPeopleUserPHIDType::TYPECONST,
array());
if ($user_phids) {
$projects = id(new PhabricatorProjectQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withMemberPHIDs($user_phids)
->withIsMilestone(false)
->execute();
$project_phids = mpull($projects, 'getPHID');
} else {
$project_phids = array();
$user_phids = array();
$project_phids = array();
foreach ($owners as $owner) {
$owner_phid = $owner->getUserPHID();
switch (phid_get_type($owner_phid)) {
case PhabricatorPeopleUserPHIDType::TYPECONST:
$user_phids[] = $owner_phid;
break;
case PhabricatorProjectProjectPHIDType::TYPECONST:
$project_phids[] = $owner_phid;
break;
}
}
$all_phids = array_fuse($user_phids) + array_fuse($project_phids);
if ($project_phids) {
$projects = id(new PhabricatorProjectQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withPHIDs($project_phids)
->needMembers(true)
->execute();
foreach ($projects as $project) {
foreach ($project->getMemberPHIDs() as $member_phid) {
$user_phids[] = $member_phid;
}
}
}
return array_values($all_phids);
$user_phids = array_fuse($user_phids);
return array_values($user_phids);
}
}