@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.

Allow users to resign if they have authority over any reviewer

Summary:
Ref T11050. The old rule was "you can only resign if you're a reviewer".

With the new behavior of "resign", the rule should be "you can resign if you're a reviewer, or you have authority over any reviewer". Make it so.

Also fixes T12446. I don't know how to reproduce that but I'm pretty sure this'll fix it?

Test Plan:
- Could not resign from a revision with no authority/reviewer.
- Resigned from a revision with myself as a reviewer.
- Resigned from a revision with a package I owned as a reviewer.
- Could not resign from a revision I had already resigned from.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12446, T11050

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

+30 -4
+13 -4
src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
··· 44 44 45 45 public function generateOldValue($object) { 46 46 $actor = $this->getActor(); 47 - return !$this->isViewerAnyReviewer($object, $actor); 47 + $resigned = DifferentialReviewerStatus::STATUS_RESIGNED; 48 + 49 + return ($this->getViewerReviewerStatus($object, $actor) == $resigned); 48 50 } 49 51 50 52 public function applyExternalEffects($object, $value) { ··· 61 63 'been closed. You can only resign from open revisions.')); 62 64 } 63 65 64 - if (!$this->isViewerAnyReviewer($object, $viewer)) { 66 + $resigned = DifferentialReviewerStatus::STATUS_RESIGNED; 67 + if ($this->getViewerReviewerStatus($object, $viewer) == $resigned) { 68 + throw new Exception( 69 + pht( 70 + 'You can not resign from this revision because you have already '. 71 + 'resigned.')); 72 + } 73 + 74 + if (!$this->isViewerAnyAuthority($object, $viewer)) { 65 75 throw new Exception( 66 76 pht( 67 77 'You can not resign from this revision because you are not a '. 68 - 'reviewer. You can only resign from revisions where you are a '. 69 - 'reviewer.')); 78 + 'reviewer, and do not have authority over any reviewer.')); 70 79 } 71 80 } 72 81
+14
src/applications/differential/xaction/DifferentialRevisionReviewTransaction.php
··· 33 33 return ($this->getViewerReviewerStatus($revision, $viewer) !== null); 34 34 } 35 35 36 + protected function isViewerAnyAuthority( 37 + DifferentialRevision $revision, 38 + PhabricatorUser $viewer) { 39 + 40 + $reviewers = $revision->getReviewers(); 41 + foreach ($revision->getReviewers() as $reviewer) { 42 + if ($reviewer->hasAuthority($viewer)) { 43 + return true; 44 + } 45 + } 46 + 47 + return false; 48 + } 49 + 36 50 protected function isViewerFullyAccepted( 37 51 DifferentialRevision $revision, 38 52 PhabricatorUser $viewer) {
+3
src/applications/differential/xaction/DifferentialRevisionTransactionType.php
··· 60 60 protected function getActiveDiffPHID(DifferentialRevision $revision) { 61 61 try { 62 62 $diff = $revision->getActiveDiff(); 63 + if (!$diff) { 64 + return null; 65 + } 63 66 return $diff->getPHID(); 64 67 } catch (Exception $ex) { 65 68 return null;