From 889eac44ae8263eb9f21b09a5531b8d833140408 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Sep 2013 14:32:41 -0700 Subject: [PATCH] Route attached objects through new editor Summary: Ref T2217. Nothing too surprising here. This transaction type is weird and should be replaced with the mainstream EDGE type at some point after things clear up more. Test Plan: Attached and detached revisions and mocks. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7085 --- .../editor/ManiphestTransactionEditorPro.php | 9 +++++++++ .../event/ManiphestEdgeEventListener.php | 20 ++++++++++--------- ...habricatorApplicationTransactionEditor.php | 13 ++++++++++-- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php index 617ecede6a..fe992aa1a0 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php @@ -15,6 +15,7 @@ final class ManiphestTransactionEditorPro $types[] = ManiphestTransactionPro::TYPE_CCS; $types[] = ManiphestTransactionPro::TYPE_PROJECTS; $types[] = ManiphestTransactionPro::TYPE_ATTACH; + $types[] = ManiphestTransactionPro::TYPE_EDGE; return $types; } @@ -40,6 +41,9 @@ final class ManiphestTransactionEditorPro return $object->getProjectPHIDs(); case ManiphestTransactionPro::TYPE_ATTACH: return $object->getAttached(); + case ManiphestTransactionPro::TYPE_EDGE: + // These are pre-populated. + return $xaction->getOldValue(); } } @@ -58,6 +62,7 @@ final class ManiphestTransactionEditorPro case ManiphestTransactionPro::TYPE_CCS: case ManiphestTransactionPro::TYPE_PROJECTS: case ManiphestTransactionPro::TYPE_ATTACH: + case ManiphestTransactionPro::TYPE_EDGE: return $xaction->getNewValue(); } @@ -84,6 +89,10 @@ final class ManiphestTransactionEditorPro return $object->setProjectPHIDs($xaction->getNewValue()); case ManiphestTransactionPro::TYPE_ATTACH: return $object->setAttached($xaction->getNewValue()); + case ManiphestTransactionPro::TYPE_EDGE: + // These are a weird, funky mess and are already being applied by the + // time we reach this. + return; } } diff --git a/src/applications/maniphest/event/ManiphestEdgeEventListener.php b/src/applications/maniphest/event/ManiphestEdgeEventListener.php index 2e79789619..1fbae1f9fa 100644 --- a/src/applications/maniphest/event/ManiphestEdgeEventListener.php +++ b/src/applications/maniphest/event/ManiphestEdgeEventListener.php @@ -55,9 +55,16 @@ final class ManiphestEdgeEventListener extends PhutilEventListener { unset($this->edges[$id]); unset($this->tasks[$id]); + $content_source = PhabricatorContentSource::newForSource( + PhabricatorContentSource::SOURCE_LEGACY, + array()); + $new_edges = $this->loadAllEdges($event); - $editor = new ManiphestTransactionEditor(); - $editor->setActor($event->getUser()); + $editor = id(new ManiphestTransactionEditorPro()) + ->setActor($event->getUser()) + ->setContentSource($content_source) + ->setContinueOnNoEffect(true) + ->setContinueOnMissingFields(true); foreach ($tasks as $phid => $task) { $xactions = array(); @@ -74,16 +81,11 @@ final class ManiphestEdgeEventListener extends PhutilEventListener { continue; } - $xactions[] = id(new ManiphestTransaction()) + $xactions[] = id(new ManiphestTransactionPro()) ->setTransactionType(ManiphestTransactionType::TYPE_EDGE) ->setOldValue($old_type) ->setNewValue($new_type) - ->setMetadataValue('edge:type', $type) - ->setContentSource( - PhabricatorContentSource::newForSource( - PhabricatorContentSource::SOURCE_LEGACY, - array())) - ->setAuthorPHID($event->getUser()->getPHID()); + ->setMetadataValue('edge:type', $type); } if ($xactions) { diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 254969cb2b..09d4b44740 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -657,8 +657,17 @@ abstract class PhabricatorApplicationTransactionEditor "You can not apply transactions which already have commentVersions!"); } - $custom_field_type = PhabricatorTransactions::TYPE_CUSTOMFIELD; - if ($xaction->getTransactionType() != $custom_field_type) { + $exempt_types = array( + // CustomField logic currently prefills these before we enter the + // transaction editor. + PhabricatorTransactions::TYPE_CUSTOMFIELD => true, + + // TODO: Remove this, this edge type is encumbered with a bunch of + // legacy nonsense. + ManiphestTransactionPro::TYPE_EDGE => true, + ); + + if (empty($exempt_types[$xaction->getTransactionType()])) { if ($xaction->getOldValue() !== null) { throw new Exception( "You can not apply transactions which already have oldValue!");