From 2bc46f097efaf4e41dd5e77309bb0ec36955bc4c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Sep 2013 14:32:08 -0700 Subject: [PATCH] Run Maniphest Conduit writes through new editor Summary: Ref T2217. Swap the editors for the Conduit writes. Test Plan: Made a bazillion Conduit calls, saw tasks updated appropriately. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7082 --- .../conduit/ConduitAPI_maniphest_Method.php | 29 +++++++----- .../editor/ManiphestTransactionEditorPro.php | 45 ++++++++++++++++++- .../PhabricatorStandardCustomField.php | 1 + 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php index 00fdd4aa75..aa6a652bfc 100644 --- a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php +++ b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php @@ -138,28 +138,27 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { $changes[ManiphestTransactionType::TYPE_ATTACH] = $attached; } - $content_source = PhabricatorContentSource::newForSource( - PhabricatorContentSource::SOURCE_CONDUIT, - array()); - - $template = new ManiphestTransaction(); - $template->setContentSource($content_source); - $template->setAuthorPHID($request->getUser()->getPHID()); + $template = new ManiphestTransactionPro(); $transactions = array(); foreach ($changes as $type => $value) { $transaction = clone $template; $transaction->setTransactionType($type); - $transaction->setNewValue($value); if ($type == PhabricatorTransactions::TYPE_COMMENT) { - $transaction->setComments($comments); + $transaction->attachComment( + id(new ManiphestTransactionComment()) + ->setContent($comments)); + } else { + $transaction->setNewValue($value); } + $transactions[] = $transaction; } $field_list = PhabricatorCustomField::getObjectFields( $task, PhabricatorCustomField::ROLE_EDIT); + $field_list->readFieldsFromStorage($task); $auxiliary = $request->getValue('auxiliary'); if ($auxiliary) { @@ -196,9 +195,15 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { $task = $event->getValue('task'); $transactions = $event->getValue('transactions'); - $editor = new ManiphestTransactionEditor(); - $editor->setActor($request->getUser()); - $editor->setAuxiliaryFields($field_list->getFields()); + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_CONDUIT, + array()); + + $editor = id(new ManiphestTransactionEditorPro()) + ->setActor($request->getUser()) + ->setContentSource($content_source) + ->setContinueOnNoEffect(true); + $editor->applyTransactions($task, $transactions); $event = new PhabricatorEvent( diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php index cea7325f87..617ecede6a 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php @@ -8,6 +8,13 @@ final class ManiphestTransactionEditorPro $types[] = PhabricatorTransactions::TYPE_COMMENT; $types[] = ManiphestTransactionPro::TYPE_PRIORITY; + $types[] = ManiphestTransactionPro::TYPE_STATUS; + $types[] = ManiphestTransactionPro::TYPE_TITLE; + $types[] = ManiphestTransactionPro::TYPE_DESCRIPTION; + $types[] = ManiphestTransactionPro::TYPE_OWNER; + $types[] = ManiphestTransactionPro::TYPE_CCS; + $types[] = ManiphestTransactionPro::TYPE_PROJECTS; + $types[] = ManiphestTransactionPro::TYPE_ATTACH; return $types; } @@ -18,7 +25,21 @@ final class ManiphestTransactionEditorPro switch ($xaction->getTransactionType()) { case ManiphestTransactionPro::TYPE_PRIORITY: - return $object->getPriority(); + return (int)$object->getPriority(); + case ManiphestTransactionPro::TYPE_STATUS: + return (int)$object->getStatus(); + case ManiphestTransactionPro::TYPE_TITLE: + return $object->getTitle(); + case ManiphestTransactionPro::TYPE_DESCRIPTION: + return $object->getDescription(); + case ManiphestTransactionPro::TYPE_OWNER: + return $object->getOwnerPHID(); + case ManiphestTransactionPro::TYPE_CCS: + return $object->getCCPHIDs(); + case ManiphestTransactionPro::TYPE_PROJECTS: + return $object->getProjectPHIDs(); + case ManiphestTransactionPro::TYPE_ATTACH: + return $object->getAttached(); } } @@ -29,6 +50,14 @@ final class ManiphestTransactionEditorPro switch ($xaction->getTransactionType()) { case ManiphestTransactionPro::TYPE_PRIORITY: + case ManiphestTransactionPro::TYPE_STATUS: + return (int)$xaction->getNewValue(); + case ManiphestTransactionPro::TYPE_TITLE: + case ManiphestTransactionPro::TYPE_DESCRIPTION: + case ManiphestTransactionPro::TYPE_OWNER: + case ManiphestTransactionPro::TYPE_CCS: + case ManiphestTransactionPro::TYPE_PROJECTS: + case ManiphestTransactionPro::TYPE_ATTACH: return $xaction->getNewValue(); } @@ -41,6 +70,20 @@ final class ManiphestTransactionEditorPro switch ($xaction->getTransactionType()) { case ManiphestTransactionPro::TYPE_PRIORITY: return $object->setPriority($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_STATUS: + return $object->setStatus($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_TITLE: + return $object->setTitle($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_DESCRIPTION: + return $object->setDescription($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_OWNER: + return $object->setOwnerPHID($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_CCS: + return $object->setCCPHIDs($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_PROJECTS: + return $object->setProjectPHIDs($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_ATTACH: + return $object->setAttached($xaction->getNewValue()); } } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php index a09efcaac0..ec42904f2b 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -272,6 +272,7 @@ abstract class PhabricatorStandardCustomField if ($this->getRequired()) { $value = $this->getOldValueForApplicationTransactions(); + $transaction = null; foreach ($xactions as $xaction) { $value = $xaction->getNewValue();