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

Correct self-review check in Differential

Summary: This check is currently wrong -- the actor is only //coincidentally// the owner (and only most of the time). It also raises at parse time, preventing any user from parsing a message with their own name in the "Reviewers" field. Instead, check against the right owner PHID and raise it only if a revision is available. See https://github.com/facebook/arcanist/issues/54 and next diff.

Test Plan: Tried to add myself as a reviewer to revisions I own via web and Conduit, got rejected. Parsed a message with myself in the "Reviewers:" field, it worked correctly.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

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

+27 -7
+11
src/applications/differential/field/specification/DifferentialFieldSpecification.php
··· 841 841 return $this->revision; 842 842 } 843 843 844 + 845 + /** 846 + * Determine if revision context is currently available. 847 + * 848 + * @task context 849 + */ 850 + final protected function hasRevision() { 851 + return (bool)$this->revision; 852 + } 853 + 854 + 844 855 /** 845 856 * @task context 846 857 */
+16 -7
src/applications/differential/field/specification/DifferentialReviewersFieldSpecification.php
··· 61 61 } 62 62 63 63 public function validateField() { 64 - $allow_self_accept = PhabricatorEnv::getEnvConfig( 65 - 'differential.allow-self-accept', false); 66 - if (!$allow_self_accept 67 - && in_array($this->getUser()->getPHID(), $this->reviewers)) { 68 - $this->error = 'Invalid'; 69 - throw new DifferentialFieldValidationException( 70 - "You may not review your own revision!"); 64 + if (!$this->hasRevision()) { 65 + return; 66 + } 67 + 68 + $self = PhabricatorEnv::getEnvConfig('differential.allow-self-accept'); 69 + if ($self) { 70 + return; 71 + } 72 + 73 + $author_phid = $this->getRevision()->getAuthorPHID(); 74 + if (!in_array($author_phid, $this->reviewers)) { 75 + return; 71 76 } 77 + 78 + $this->error = 'Invalid'; 79 + throw new DifferentialFieldValidationException( 80 + "The owner of a revision may not be a reviewer."); 72 81 } 73 82 74 83 public function renderEditControl() {