From f5f7987013977c57e8bc8a4ffb0aaf16b15f1e13 Mon Sep 17 00:00:00 2001 From: vrana Date: Mon, 5 Mar 2012 10:51:47 -0800 Subject: [PATCH] Revert rP87c60abbd02d, apply D1772 Test Plan: Apply SQL patch. Visit /differential/. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1781 --- resources/sql/patches/113.lastreviewer.sql | 12 +++++++++++ .../comment/DifferentialCommentEditor.php | 6 ++++++ ...ifferentialReviewersFieldSpecification.php | 20 ++++++++++--------- .../storage/revision/DifferentialRevision.php | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 resources/sql/patches/113.lastreviewer.sql diff --git a/resources/sql/patches/113.lastreviewer.sql b/resources/sql/patches/113.lastreviewer.sql new file mode 100644 index 0000000000..5924647815 --- /dev/null +++ b/resources/sql/patches/113.lastreviewer.sql @@ -0,0 +1,12 @@ +ALTER TABLE `phabricator_differential`.`differential_revision` + ADD `lastReviewerPHID` varchar(64) BINARY AFTER `authorPHID`; + +UPDATE `phabricator_differential`.`differential_revision` +SET `lastReviewerPHID` = ( + SELECT `authorPHID` + FROM `differential_comment` + WHERE `revisionID` = `differential_revision`.`id` + AND `action` IN ('accept', 'reject') + ORDER BY `id` DESC + LIMIT 1 +); diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index 3498f421d6..c6a6afa062 100644 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -386,6 +386,12 @@ class DifferentialCommentEditor { throw new Exception('Unsupported action.'); } + // Update information about reviewer in charge. + if ($action == DifferentialAction::ACTION_ACCEPT || + $action == DifferentialAction::ACTION_REJECT) { + $revision->setLastReviewerPHID($actor_phid); + } + // Always save the revision (even if we didn't actually change any of its // properties) so that it jumps to the top of the revision list when sorted // by "updated". Notably, this allows "ping" comments to push it to the diff --git a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php index 3d3f0fbb32..6934bf1dd9 100644 --- a/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php +++ b/src/applications/differential/field/specification/reviewers/DifferentialReviewersFieldSpecification.php @@ -19,7 +19,6 @@ final class DifferentialReviewersFieldSpecification extends DifferentialFieldSpecification { - private $primaryReviewers = array(); private $reviewers; private $error; @@ -150,8 +149,8 @@ final class DifferentialReviewersFieldSpecification } public function renderValueForRevisionList(DifferentialRevision $revision) { - if (isset($this->primaryReviewers[$revision->getID()])) { - $primary_reviewer = $this->primaryReviewers[$revision->getID()]; + $primary_reviewer = $this->getPrimaryReviewer($revision); + if ($primary_reviewer) { $other_reviewers = array_flip($revision->getReviewers()); unset($other_reviewers[$primary_reviewer]); if ($other_reviewers) { @@ -167,16 +166,19 @@ final class DifferentialReviewersFieldSpecification public function getRequiredHandlePHIDsForRevisionList( DifferentialRevision $revision) { - $primary_reviewer = $revision->loadReviewedBy(); - if (!$primary_reviewer) { - $reviewer_phids = $revision->getReviewers(); - $primary_reviewer = reset($reviewer_phids); - } + $primary_reviewer = $this->getPrimaryReviewer($revision); if ($primary_reviewer) { - $this->primaryReviewers[$revision->getID()] = $primary_reviewer; return array($primary_reviewer); } return array(); } + private function getPrimaryReviewer(DifferentialRevision $revision) { + $primary_reviewer = $revision->getLastReviewerPHID(); + if (!$primary_reviewer) { + $primary_reviewer = head($revision->getReviewers()); + } + return $primary_reviewer; + } + } diff --git a/src/applications/differential/storage/revision/DifferentialRevision.php b/src/applications/differential/storage/revision/DifferentialRevision.php index e203ed183c..b71ed2f455 100644 --- a/src/applications/differential/storage/revision/DifferentialRevision.php +++ b/src/applications/differential/storage/revision/DifferentialRevision.php @@ -26,6 +26,7 @@ class DifferentialRevision extends DifferentialDAO { protected $phid; protected $authorPHID; + protected $lastReviewerPHID; protected $dateCommitted;