From 725e2fa410556f37dfcc4dc9ad34be8295a70dfb Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 4 Aug 2014 12:03:48 -0700 Subject: [PATCH] Write a "resign" audit relationship even if actor has no relationship Summary: Ref T4896. I got this logic slightly wrong when porting it over: we always want to write this relationship, to allow members of a project with an audit request against a commit to resign and get it out of their queue. Test Plan: - Resigned from a commit with an existing relationship. - Resigned from a commit with no existing relationship, saw one added. Reviewers: btrahan, joshuaspence, mbishopim3 Reviewed By: mbishopim3 Subscribers: epriestley Maniphest Tasks: T4896 Differential Revision: https://secure.phabricator.com/D10137 --- .../audit/editor/PhabricatorAuditEditor.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php index 74edd7e15d..ab09d49157 100644 --- a/src/applications/audit/editor/PhabricatorAuditEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditEditor.php @@ -161,11 +161,23 @@ final class PhabricatorAuditEditor $requests = mpull($requests, null, 'getAuditorPHID'); $actor_request = idx($requests, $actor_phid); - if ($actor_request) { - $actor_request - ->setAuditStatus($status_resigned) - ->save(); + // If the actor doesn't currently have a relationship to the + // commit, add one explicitly. For example, this allows members + // of a project to resign from a commit and have it drop out of + // their queue. + + if (!$actor_request) { + $actor_request = id(new PhabricatorRepositoryAuditRequest()) + ->setCommitPHID($object->getPHID()) + ->setAuditorPHID($actor_phid); + + $requests[] = $actor_request; + $object->attachAudits($requests); } + + $actor_request + ->setAuditStatus($status_resigned) + ->save(); break; case PhabricatorAuditActionConstants::ACCEPT: case PhabricatorAuditActionConstants::CONCERN: