mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Fix packages(project)
to work properly and add it to "MailableFunctionDatasource"
Summary: Ref T13210. See PHI937. This function datasource isn't quite implemented correctly: it doesn't resolve `package(project)` properly, since the logic only handles users. This blames back to D14013, where it looks like `packages(..)` was added mostly as a general nice-to-have as part of a larger modernization change. Test Plan: Ran a `packages(project)` query in Differential, got accurate results (previously: no results). Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13210 Differential Revision: https://secure.phabricator.com/D19747
This commit is contained in:
parent
bc6c8c0e93
commit
e0dea4c486
2 changed files with 18 additions and 9 deletions
|
@ -23,6 +23,7 @@ final class PhabricatorMetaMTAMailableFunctionDatasource
|
|||
new PhabricatorProjectMembersDatasource(),
|
||||
new PhabricatorProjectDatasource(),
|
||||
new PhabricatorOwnersPackageDatasource(),
|
||||
new PhabricatorOwnersPackageOwnerDatasource(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ final class PhabricatorOwnersPackageOwnerDatasource
|
|||
'packages' => array(
|
||||
'name' => pht('Packages: ...'),
|
||||
'arguments' => pht('owner'),
|
||||
'summary' => pht("Find results in any of an owner's projects."),
|
||||
'summary' => pht("Find results in any of an owner's packages."),
|
||||
'description' => pht(
|
||||
"This function allows you to find results associated with any ".
|
||||
"of the packages a specified user or project is an owner of. ".
|
||||
|
@ -61,18 +61,21 @@ final class PhabricatorOwnersPackageOwnerDatasource
|
|||
|
||||
$phids = $this->resolvePHIDs($phids);
|
||||
|
||||
$user_phids = array();
|
||||
$owner_phids = array();
|
||||
foreach ($phids as $key => $phid) {
|
||||
if (phid_get_type($phid) == PhabricatorPeopleUserPHIDType::TYPECONST) {
|
||||
$user_phids[] = $phid;
|
||||
unset($phids[$key]);
|
||||
switch (phid_get_type($phid)) {
|
||||
case PhabricatorPeopleUserPHIDType::TYPECONST:
|
||||
case PhabricatorProjectProjectPHIDType::TYPECONST:
|
||||
$owner_phids[] = $phid;
|
||||
unset($phids[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($user_phids) {
|
||||
if ($owner_phids) {
|
||||
$packages = id(new PhabricatorOwnersPackageQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withOwnerPHIDs($user_phids)
|
||||
->withOwnerPHIDs($owner_phids)
|
||||
->execute();
|
||||
foreach ($packages as $package) {
|
||||
$phids[] = $package->getPHID();
|
||||
|
@ -116,8 +119,13 @@ final class PhabricatorOwnersPackageOwnerDatasource
|
|||
|
||||
$usernames = array();
|
||||
foreach ($phids as $key => $phid) {
|
||||
if (phid_get_type($phid) != PhabricatorPeopleUserPHIDType::TYPECONST) {
|
||||
$usernames[$key] = $phid;
|
||||
switch (phid_get_type($phid)) {
|
||||
case PhabricatorPeopleUserPHIDType::TYPECONST:
|
||||
case PhabricatorProjectProjectPHIDType::TYPECONST:
|
||||
break;
|
||||
default:
|
||||
$usernames[$key] = $phid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue