From 520d3b9392041893e10b43a133263c49b5d341aa Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 3 Apr 2017 08:35:29 -0700 Subject: [PATCH] (stable) Don't downgrade accepts on update (fix "sticky accept") Summary: Fixes T12496. Sticky accept was accidentally impacted by the "void" changes in D17566. Instead, don't always downgrade all accepts/rejects: on update, we only want to downgrade accepts. Test Plan: - With sticky accept off, updated an accepted revision: new state is "needs review". - With sticky accept on, updated an accepted revision: new state is "accepted" (sticky accept working correctly). - Did "reject" + "request review" to make sure that still works, worked fine. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12496 Differential Revision: https://secure.phabricator.com/D17605 --- .../editor/DifferentialTransactionEditor.php | 14 ++++++++++++-- .../DifferentialRevisionVoidTransaction.php | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php index bf7faa2700..f24bc7abda 100644 --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -339,12 +339,22 @@ final class DifferentialTransactionEditor } } - if ($downgrade_accepts || $downgrade_rejects) { + $downgrade = array(); + if ($downgrade_accepts) { + $downgrade[] = DifferentialReviewerStatus::STATUS_ACCEPTED; + } + + if ($downgrade_accepts) { + $downgrade[] = DifferentialReviewerStatus::STATUS_REJECTED; + } + + if ($downgrade) { $void_type = DifferentialRevisionVoidTransaction::TRANSACTIONTYPE; + $results[] = id(new DifferentialTransaction()) ->setTransactionType($void_type) ->setIgnoreOnNoEffect(true) - ->setNewValue(true); + ->setNewValue($downgrade); } $is_commandeer = false; diff --git a/src/applications/differential/xaction/DifferentialRevisionVoidTransaction.php b/src/applications/differential/xaction/DifferentialRevisionVoidTransaction.php index ae684d94fe..5073a9c464 100644 --- a/src/applications/differential/xaction/DifferentialRevisionVoidTransaction.php +++ b/src/applications/differential/xaction/DifferentialRevisionVoidTransaction.php @@ -28,7 +28,7 @@ final class DifferentialRevisionVoidTransaction AND reviewerStatus IN (%Ls)', $table_name, $object->getPHID(), - $this->getVoidableStatuses()); + $value); return ipull($rows, 'reviewerPHID'); } @@ -47,11 +47,11 @@ final class DifferentialRevisionVoidTransaction 'UPDATE %T SET voidedPHID = %s WHERE revisionPHID = %s AND voidedPHID IS NULL - AND reviewerStatus IN (%Ls)', + AND reviewerPHID IN (%Ls)', $table_name, $this->getActingAsPHID(), $object->getPHID(), - $this->getVoidableStatuses()); + $value); } public function shouldHide() {