@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When predicting object policies for project milestones, adjust objects so they behave like milestones

Summary:
Ref T13462. Currently, when testing milestone edit policies during creation, the project object does not behave like a milestone:

- it doesn't have a milestone number yet, so it doesn't try to access the parent project; and
- the parent project isn't attached yet.

Instead: attach the parent project sooner (which "should" be harmless, although it's possible this has weird side effects); and give the adjusted policy object a dummy milestone number if it doesn't have one yet. This forces it to act like a milestone when emitting policies.

Test Plan:
- Set "Projects" application default edit policy to "No One".
- Created a milestone I had permission to create.
- Before: failed with a policy error, because the project behaved like a non-milestone and returned "No One" as the effective edit policy.
- After: worked properly, correctly evaluting the parent project edit policy as the effective edit policy.
- Tried to create a milestone I did not have permission to create (no edit permission on parent project).
- Got an appropriate edit policy error.

Maniphest Tasks: T13462

Differential Revision: https://secure.phabricator.com/D20919

+11 -3
+1 -2
src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
··· 1537 1537 PhabricatorProject $parent = null, 1538 1538 $is_milestone = false) { 1539 1539 1540 - $project = PhabricatorProject::initializeNewProject($user); 1541 - 1540 + $project = PhabricatorProject::initializeNewProject($user, $parent); 1542 1541 1543 1542 $name = pht('Test Project %d', mt_rand()); 1544 1543
+9
src/applications/project/editor/PhabricatorProjectTransactionEditor.php
··· 336 336 $type_edge = PhabricatorTransactions::TYPE_EDGE; 337 337 $edgetype_member = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; 338 338 339 + // See T13462. If we're creating a milestone, set a dummy milestone 340 + // number so the project behaves like a milestone and uses milestone 341 + // policy rules. Otherwise, we'll end up checking the default policies 342 + // (which are not relevant to milestones) instead of the parent project 343 + // policies (which are the correct policies). 344 + if ($this->getIsMilestone() && !$copy->isMilestone()) { 345 + $copy->setMilestoneNumber(1); 346 + } 347 + 339 348 $member_xaction = null; 340 349 foreach ($xactions as $xaction) { 341 350 if ($xaction->getTransactionType() !== $type_edge) {
+1 -1
src/applications/project/storage/PhabricatorProject.php
··· 107 107 ->setHasMilestones(0) 108 108 ->setHasSubprojects(0) 109 109 ->setSubtype(PhabricatorEditEngineSubtype::SUBTYPE_DEFAULT) 110 - ->attachParentProject(null); 110 + ->attachParentProject($parent); 111 111 } 112 112 113 113 public function getCapabilities() {