1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Prevent "Maniphest Tasks" field from creating empty comment when revisions are

updated

Summary:
  - If you update a revision with a nonempty "Maniphest Tasks" field, an empty
comment is posted (see T586).
  - The transaction email currently says "Attached revision 'Unknown
Differential Revision'", move attaching to "didWriteRevision()" to make sure the
object has been written.

Test Plan:   - Attached; updated a revision.

Reviewers: btrahan, jungejason

Reviewed By: btrahan

CC: aran, btrahan

Maniphest Tasks: T685

Differential Revision: 1223
This commit is contained in:
epriestley 2011-12-16 13:26:18 -08:00
parent 3cd92ab075
commit dfc3506240

View file

@ -58,7 +58,7 @@ final class DifferentialManiphestTasksFieldSpecification
* *
* @return void * @return void
*/ */
public function willWriteRevision(DifferentialRevisionEditor $editor) { public function didWriteRevision(DifferentialRevisionEditor $editor) {
// 1 -- revision => tasks // 1 -- revision => tasks
$revision = $editor->getRevision(); $revision = $editor->getRevision();
$revision->setAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_TASK, $revision->setAttachedPHIDs(PhabricatorPHIDConstants::PHID_TYPE_TASK,
@ -86,6 +86,11 @@ final class DifferentialManiphestTasksFieldSpecification
if (empty($new[$attach_type])) { if (empty($new[$attach_type])) {
$new[$attach_type] = array(); $new[$attach_type] = array();
} }
if (array_key_exists($revision->getPHID(), $new[$attach_type])) {
// Already attached, just skip the update.
continue;
}
$new[$attach_type][$revision->getPHID()] = array(); $new[$attach_type][$revision->getPHID()] = array();
$transaction->setNewValue($new); $transaction->setNewValue($new);