Differential D17514 Diff 42139 src/applications/differential/editor/DifferentialTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/editor/DifferentialTransactionEditor.php
Show First 20 Lines • Show All 712 Lines • ▼ Show 20 Lines | switch ($old_status) { | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
// Revisions can't transition out of other statuses (like closed or | // Revisions can't transition out of other statuses (like closed or | ||||
// abandoned) as a side effect of reviewer status changes. | // abandoned) as a side effect of reviewer status changes. | ||||
break; | break; | ||||
} | } | ||||
$this->markReviewerComments($object, $xactions); | |||||
return $xactions; | return $xactions; | ||||
} | } | ||||
protected function validateTransaction( | protected function validateTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
$type, | $type, | ||||
array $xactions) { | array $xactions) { | ||||
▲ Show 20 Lines • Show All 1,102 Lines • ▼ Show 20 Lines | private function newCommandeerReviewerTransaction( | ||||
return id(new DifferentialTransaction()) | return id(new DifferentialTransaction()) | ||||
->setTransactionType($xaction_type) | ->setTransactionType($xaction_type) | ||||
->setIgnoreOnNoEffect(true) | ->setIgnoreOnNoEffect(true) | ||||
->setIsCommandeerSideEffect(true) | ->setIsCommandeerSideEffect(true) | ||||
->setNewValue($edits); | ->setNewValue($edits); | ||||
} | } | ||||
public function getActiveDiff($object) { | |||||
if ($this->getIsNewObject()) { | |||||
return null; | |||||
} else { | |||||
return $object->getActiveDiff(); | |||||
} | |||||
} | |||||
/** | |||||
* When a reviewer makes a comment, mark the last revision they commented | |||||
* on. | |||||
* | |||||
* This allows us to show a hint to help authors and other reviewers quickly | |||||
* distinguish between reviewers who have participated in the discussion and | |||||
* reviewers who haven't been part of it. | |||||
*/ | |||||
private function markReviewerComments($object, array $xactions) { | |||||
$acting_phid = $this->getActingAsPHID(); | |||||
if (!$acting_phid) { | |||||
return; | |||||
} | |||||
$diff = $this->getActiveDiff($object); | |||||
if (!$diff) { | |||||
return; | |||||
} | |||||
$has_comment = false; | |||||
foreach ($xactions as $xaction) { | |||||
if ($xaction->hasComment()) { | |||||
$has_comment = true; | |||||
break; | |||||
} | |||||
} | |||||
if (!$has_comment) { | |||||
return; | |||||
} | |||||
$reviewer_table = new DifferentialReviewer(); | |||||
$conn = $reviewer_table->establishConnection('w'); | |||||
queryfx( | |||||
$conn, | |||||
'UPDATE %T SET lastCommentDiffPHID = %s | |||||
WHERE revisionPHID = %s | |||||
AND reviewerPHID = %s', | |||||
$reviewer_table->getTableName(), | |||||
$diff->getPHID(), | |||||
$object->getPHID(), | |||||
$acting_phid); | |||||
} | |||||
} | } |