1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

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
This commit is contained in:
epriestley 2013-09-23 14:32:41 -07:00
parent 9afbb9b83b
commit 889eac44ae
3 changed files with 31 additions and 11 deletions

View file

@ -15,6 +15,7 @@ final class ManiphestTransactionEditorPro
$types[] = ManiphestTransactionPro::TYPE_CCS; $types[] = ManiphestTransactionPro::TYPE_CCS;
$types[] = ManiphestTransactionPro::TYPE_PROJECTS; $types[] = ManiphestTransactionPro::TYPE_PROJECTS;
$types[] = ManiphestTransactionPro::TYPE_ATTACH; $types[] = ManiphestTransactionPro::TYPE_ATTACH;
$types[] = ManiphestTransactionPro::TYPE_EDGE;
return $types; return $types;
} }
@ -40,6 +41,9 @@ final class ManiphestTransactionEditorPro
return $object->getProjectPHIDs(); return $object->getProjectPHIDs();
case ManiphestTransactionPro::TYPE_ATTACH: case ManiphestTransactionPro::TYPE_ATTACH:
return $object->getAttached(); 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_CCS:
case ManiphestTransactionPro::TYPE_PROJECTS: case ManiphestTransactionPro::TYPE_PROJECTS:
case ManiphestTransactionPro::TYPE_ATTACH: case ManiphestTransactionPro::TYPE_ATTACH:
case ManiphestTransactionPro::TYPE_EDGE:
return $xaction->getNewValue(); return $xaction->getNewValue();
} }
@ -84,6 +89,10 @@ final class ManiphestTransactionEditorPro
return $object->setProjectPHIDs($xaction->getNewValue()); return $object->setProjectPHIDs($xaction->getNewValue());
case ManiphestTransactionPro::TYPE_ATTACH: case ManiphestTransactionPro::TYPE_ATTACH:
return $object->setAttached($xaction->getNewValue()); 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;
} }
} }

View file

@ -55,9 +55,16 @@ final class ManiphestEdgeEventListener extends PhutilEventListener {
unset($this->edges[$id]); unset($this->edges[$id]);
unset($this->tasks[$id]); unset($this->tasks[$id]);
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array());
$new_edges = $this->loadAllEdges($event); $new_edges = $this->loadAllEdges($event);
$editor = new ManiphestTransactionEditor(); $editor = id(new ManiphestTransactionEditorPro())
$editor->setActor($event->getUser()); ->setActor($event->getUser())
->setContentSource($content_source)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true);
foreach ($tasks as $phid => $task) { foreach ($tasks as $phid => $task) {
$xactions = array(); $xactions = array();
@ -74,16 +81,11 @@ final class ManiphestEdgeEventListener extends PhutilEventListener {
continue; continue;
} }
$xactions[] = id(new ManiphestTransaction()) $xactions[] = id(new ManiphestTransactionPro())
->setTransactionType(ManiphestTransactionType::TYPE_EDGE) ->setTransactionType(ManiphestTransactionType::TYPE_EDGE)
->setOldValue($old_type) ->setOldValue($old_type)
->setNewValue($new_type) ->setNewValue($new_type)
->setMetadataValue('edge:type', $type) ->setMetadataValue('edge:type', $type);
->setContentSource(
PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array()))
->setAuthorPHID($event->getUser()->getPHID());
} }
if ($xactions) { if ($xactions) {

View file

@ -657,8 +657,17 @@ abstract class PhabricatorApplicationTransactionEditor
"You can not apply transactions which already have commentVersions!"); "You can not apply transactions which already have commentVersions!");
} }
$custom_field_type = PhabricatorTransactions::TYPE_CUSTOMFIELD; $exempt_types = array(
if ($xaction->getTransactionType() != $custom_field_type) { // 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) { if ($xaction->getOldValue() !== null) {
throw new Exception( throw new Exception(
"You can not apply transactions which already have oldValue!"); "You can not apply transactions which already have oldValue!");