@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

Allow objects to specify custom policy unlocking behavior, and tasks to have owners unlocked

Summary: Depends on D20256. Ref T13249. See PHI1115. This primarily makes `bin/policy unlock --owner epriestley T123` work. This is important for "Edit Locked" tasks, since changing the edit policy doesn't really do anything.

Test Plan: Hard-locked a task as "alice", reassigned it to myself with `bin/policy unlock --owner epriestley`.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13249

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

+53 -2
+4
src/__phutil_library_map__.php
··· 1784 1784 'ManiphestTaskTitleTransaction' => 'applications/maniphest/xaction/ManiphestTaskTitleTransaction.php', 1785 1785 'ManiphestTaskTransactionType' => 'applications/maniphest/xaction/ManiphestTaskTransactionType.php', 1786 1786 'ManiphestTaskUnblockTransaction' => 'applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php', 1787 + 'ManiphestTaskUnlockEngine' => 'applications/maniphest/engine/ManiphestTaskUnlockEngine.php', 1787 1788 'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php', 1788 1789 'ManiphestTransactionComment' => 'applications/maniphest/storage/ManiphestTransactionComment.php', 1789 1790 'ManiphestTransactionEditor' => 'applications/maniphest/editor/ManiphestTransactionEditor.php', ··· 4703 4704 'PhabricatorUnitsTestCase' => 'view/__tests__/PhabricatorUnitsTestCase.php', 4704 4705 'PhabricatorUnknownContentSource' => 'infrastructure/contentsource/PhabricatorUnknownContentSource.php', 4705 4706 'PhabricatorUnlockEngine' => 'applications/system/engine/PhabricatorUnlockEngine.php', 4707 + 'PhabricatorUnlockableInterface' => 'applications/system/interface/PhabricatorUnlockableInterface.php', 4706 4708 'PhabricatorUnsubscribedFromObjectEdgeType' => 'applications/transactions/edges/PhabricatorUnsubscribedFromObjectEdgeType.php', 4707 4709 'PhabricatorUser' => 'applications/people/storage/PhabricatorUser.php', 4708 4710 'PhabricatorUserApproveTransaction' => 'applications/people/xaction/PhabricatorUserApproveTransaction.php', ··· 7419 7421 'PhabricatorEditEngineLockableInterface', 7420 7422 'PhabricatorEditEngineMFAInterface', 7421 7423 'PhabricatorPolicyCodexInterface', 7424 + 'PhabricatorUnlockableInterface', 7422 7425 ), 7423 7426 'ManiphestTaskAssignHeraldAction' => 'HeraldAction', 7424 7427 'ManiphestTaskAssignOtherHeraldAction' => 'ManiphestTaskAssignHeraldAction', ··· 7496 7499 'ManiphestTaskTitleTransaction' => 'ManiphestTaskTransactionType', 7497 7500 'ManiphestTaskTransactionType' => 'PhabricatorModularTransactionType', 7498 7501 'ManiphestTaskUnblockTransaction' => 'ManiphestTaskTransactionType', 7502 + 'ManiphestTaskUnlockEngine' => 'PhabricatorUnlockEngine', 7499 7503 'ManiphestTransaction' => 'PhabricatorModularTransaction', 7500 7504 'ManiphestTransactionComment' => 'PhabricatorApplicationTransactionComment', 7501 7505 'ManiphestTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
+14
src/applications/maniphest/engine/ManiphestTaskUnlockEngine.php
··· 1 + <?php 2 + 3 + final class ManiphestTaskUnlockEngine 4 + extends PhabricatorUnlockEngine { 5 + 6 + public function newUnlockOwnerTransactions($object, $user) { 7 + return array( 8 + $this->newTransaction($object) 9 + ->setTransactionType(ManiphestTaskOwnerTransaction::TRANSACTIONTYPE) 10 + ->setNewValue($user->getPHID()), 11 + ); 12 + } 13 + 14 + }
+10 -1
src/applications/maniphest/storage/ManiphestTask.php
··· 21 21 PhabricatorEditEngineSubtypeInterface, 22 22 PhabricatorEditEngineLockableInterface, 23 23 PhabricatorEditEngineMFAInterface, 24 - PhabricatorPolicyCodexInterface { 24 + PhabricatorPolicyCodexInterface, 25 + PhabricatorUnlockableInterface { 25 26 26 27 const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; 27 28 ··· 647 648 648 649 public function newPolicyCodex() { 649 650 return new ManiphestTaskPolicyCodex(); 651 + } 652 + 653 + 654 + /* -( PhabricatorUnlockableInterface )------------------------------------- */ 655 + 656 + 657 + public function newUnlockEngine() { 658 + return new ManiphestTaskUnlockEngine(); 650 659 } 651 660 652 661 }
+7 -1
src/applications/system/engine/PhabricatorUnlockEngine.php
··· 13 13 'PhabricatorApplicationTransactionInterface')); 14 14 } 15 15 16 - return new PhabricatorDefaultUnlockEngine(); 16 + if ($object instanceof PhabricatorUnlockableInterface) { 17 + $engine = $object->newUnlockEngine(); 18 + } else { 19 + $engine = new PhabricatorDefaultUnlockEngine(); 20 + } 21 + 22 + return $engine; 17 23 } 18 24 19 25 public function newUnlockViewTransactions($object, $user) {
+18
src/applications/system/interface/PhabricatorUnlockableInterface.php
··· 1 + <?php 2 + 3 + interface PhabricatorUnlockableInterface { 4 + 5 + public function newUnlockEngine(); 6 + 7 + } 8 + 9 + // TEMPLATE IMPLEMENTATION ///////////////////////////////////////////////////// 10 + 11 + /* -( PhabricatorUnlockableInterface )------------------------------------- */ 12 + /* 13 + 14 + public function newUnlockEngine() { 15 + return new <<<...>>>UnlockEngine(); 16 + } 17 + 18 + */