1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01: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)', 'packageID IN (%Ls)',
$package_ids); $package_ids);
$all_phids = phid_group_by_type(mpull($owners, 'getUserPHID')); $type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
$type_project = PhabricatorProjectProjectPHIDType::TYPECONST;
$user_phids = idx($all_phids, $user_phids = array();
PhabricatorPeopleUserPHIDType::TYPECONST, $project_phids = array();
array()); foreach ($owners as $owner) {
$owner_phid = $owner->getUserPHID();
if ($user_phids) { switch (phid_get_type($owner_phid)) {
$projects = id(new PhabricatorProjectQuery()) case PhabricatorPeopleUserPHIDType::TYPECONST:
->setViewer(PhabricatorUser::getOmnipotentUser()) $user_phids[] = $owner_phid;
->withMemberPHIDs($user_phids) break;
->withIsMilestone(false) case PhabricatorProjectProjectPHIDType::TYPECONST:
->execute(); $project_phids[] = $owner_phid;
$project_phids = mpull($projects, 'getPHID'); break;
} else { }
$project_phids = array();
} }
$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);
} }
} }