1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

When predicting project membership during edits, predict milestones will have parent membership

Summary:
Depends on D20919. Ref T13462. When editing milestones, we currently predict they will have no members for policy evaluation purposes. This isn't the right rule.

Instead, predict that their membership will be the same as the parent project's membership, and pass this hint to the policy layer.

See T13462 for additional context and discussion.

Test Plan:
  - Set project A's edit policy to "Project Members".
  - Joined project A.
  - Tried to create a milestone of project A.
    - Before: policy exception that the edit policy excludes me.
    - After: clean milestone creation.
  - As a non-member, tried to create a milestone. Received appropriate policy error.

Maniphest Tasks: T13462

Differential Revision: https://secure.phabricator.com/D20920
This commit is contained in:
epriestley 2019-11-18 22:49:40 -08:00
parent 959504a488
commit d58eddcf0a

View file

@ -345,6 +345,23 @@ final class PhabricatorProjectTransactionEditor
$copy->setMilestoneNumber(1); $copy->setMilestoneNumber(1);
} }
$hint = null;
if ($this->getIsMilestone()) {
// See T13462. If we're creating a milestone, predict that the members
// of the newly created milestone will be the same as the members of the
// parent project, since this is the governing rule.
$parent = $copy->getParentProject();
$parent = id(new PhabricatorProjectQuery())
->setViewer($this->getActor())
->withPHIDs(array($parent->getPHID()))
->needMembers(true)
->executeOne();
$members = $parent->getMemberPHIDs();
$hint = array_fuse($members);
} else {
$member_xaction = null; $member_xaction = null;
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
if ($xaction->getTransactionType() !== $type_edge) { if ($xaction->getTransactionType() !== $type_edge) {
@ -375,10 +392,12 @@ final class PhabricatorProjectTransactionEditor
$clone_xaction = clone $member_xaction; $clone_xaction = clone $member_xaction;
$hint = $this->getPHIDTransactionNewValue($clone_xaction, $members); $hint = $this->getPHIDTransactionNewValue($clone_xaction, $members);
$rule = new PhabricatorProjectMembersPolicyRule();
$hint = array_fuse($hint); $hint = array_fuse($hint);
}
}
if ($hint !== null) {
$rule = new PhabricatorProjectMembersPolicyRule();
PhabricatorPolicyRule::passTransactionHintToRule( PhabricatorPolicyRule::passTransactionHintToRule(
$copy, $copy,
$rule, $rule,