1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Discard no-op transactions from transaction groups.

Move assignees to CC as a side effect of reassignment.

Summary:

Test Plan:

Reviewers:

CC:
This commit is contained in:
epriestley 2011-02-09 12:57:38 -08:00
parent 9eccb3e23d
commit 56880cc92e
3 changed files with 39 additions and 7 deletions

View file

@ -49,6 +49,7 @@ class ManiphestTransactionSaveController extends ManiphestController {
case ManiphestTransactionType::TYPE_CCS:
$ccs = $request->getArr('ccs');
$ccs = array_merge($ccs, $task->getCCPHIDs());
$ccs = array_filter($ccs);
$ccs = array_unique($ccs);
$transaction->setNewValue($ccs);
break;
@ -59,8 +60,31 @@ class ManiphestTransactionSaveController extends ManiphestController {
throw new Exception('unknown action');
}
$transactions = array($transaction);
switch ($action) {
case ManiphestTransactionType::TYPE_OWNER:
if ($task->getOwnerPHID() == $transaction->getNewValue()) {
// If this is actually no-op, don't generate the side effect.
break;
}
// When a task is reassigned, move the previous owner to CC.
$old = $task->getCCPHIDs();
$new = array_merge(
$old,
array($task->getOwnerPHID()));
$new = array_unique(array_filter($new));
if ($old != $new) {
$cc = clone $transaction;
$cc->setTransactionType(ManiphestTransactionType::TYPE_CCS);
$cc->setNewValue($new);
$transactions[] = $cc;
}
break;
}
$editor = new ManiphestTransactionEditor();
$editor->applyTransactions($task, array($transaction));
$editor->applyTransactions($task, $transactions);
return id(new AphrontRedirectResponse())
->setURI('/T'.$task->getID());

View file

@ -25,7 +25,7 @@ class ManiphestTransactionEditor {
$email_to = array();
$email_to[] = $task->getOwnerPHID();
foreach ($transactions as $transaction) {
foreach ($transactions as $key => $transaction) {
$type = $transaction->getTransactionType();
$new = $transaction->getNewValue();
$email_to[] = $transaction->getAuthorPHID();
@ -51,9 +51,17 @@ class ManiphestTransactionEditor {
}
if (($old !== null) && ($old == $new)) {
if (count($transactions) > 1 && !$transaction->hasComments()) {
// If we have at least one other transaction and this one isn't
// doing anything and doesn't have any comments, just throw it
// away.
unset($transactions[$key]);
continue;
} else {
$transaction->setOldValue(null);
$transaction->setNewValue(null);
$transaction->setTransactionType(ManiphestTransactionType::TYPE_NONE);
}
} else {
switch ($type) {
case ManiphestTransactionType::TYPE_NONE: