diff --git a/src/applications/owners/storage/PhabricatorOwnersOwner.php b/src/applications/owners/storage/PhabricatorOwnersOwner.php --- a/src/applications/owners/storage/PhabricatorOwnersOwner.php +++ b/src/applications/owners/storage/PhabricatorOwnersOwner.php @@ -45,25 +45,37 @@ '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()); + $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; + } + } - if ($user_phids) { + if ($project_phids) { $projects = id(new PhabricatorProjectQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) - ->withMemberPHIDs($user_phids) - ->withIsMilestone(false) + ->withPHIDs($project_phids) + ->needMembers(true) ->execute(); - $project_phids = mpull($projects, 'getPHID'); - } else { - $project_phids = array(); + foreach ($projects as $project) { + foreach ($project->getMemberPHIDs() as $member_phid) { + $user_phids[] = $member_phid; + } + } } - $all_phids = array_fuse($user_phids) + array_fuse($project_phids); - - return array_values($all_phids); + $user_phids = array_fuse($user_phids); + return array_values($user_phids); } }