Differential D20131 Diff 48073 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 1,109 Lines • ▼ Show 20 Lines | try { | ||||
->setActingAsPHID($this->getActingAsPHID()) | ->setActingAsPHID($this->getActingAsPHID()) | ||||
->setContentSource($this->getContentSource()); | ->setContentSource($this->getContentSource()); | ||||
if (!$transaction_open) { | if (!$transaction_open) { | ||||
$object->openTransaction(); | $object->openTransaction(); | ||||
$transaction_open = true; | $transaction_open = true; | ||||
} | } | ||||
// We can technically test any object for CAN_INTERACT, but we can | |||||
// run into some issues in doing so (for example, in project unit tests). | |||||
// For now, only test for CAN_INTERACT if the object is explicitly a | |||||
// lockable object. | |||||
$was_locked = false; | |||||
if ($object instanceof PhabricatorEditEngineLockableInterface) { | |||||
$was_locked = !PhabricatorPolicyFilter::canInteract($actor, $object); | |||||
} | |||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
$this->applyInternalEffects($object, $xaction); | $this->applyInternalEffects($object, $xaction); | ||||
} | } | ||||
$xactions = $this->didApplyInternalEffects($object, $xactions); | $xactions = $this->didApplyInternalEffects($object, $xactions); | ||||
try { | try { | ||||
$object->save(); | $object->save(); | ||||
} catch (AphrontDuplicateKeyQueryException $ex) { | } catch (AphrontDuplicateKeyQueryException $ex) { | ||||
// This callback has an opportunity to throw a better exception, | // This callback has an opportunity to throw a better exception, | ||||
// so execution may end here. | // so execution may end here. | ||||
$this->didCatchDuplicateKeyException($object, $xactions, $ex); | $this->didCatchDuplicateKeyException($object, $xactions, $ex); | ||||
throw $ex; | throw $ex; | ||||
} | } | ||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if ($was_locked) { | |||||
$xaction->setIsLockOverrideTransaction(true); | |||||
} | |||||
$xaction->setObjectPHID($object->getPHID()); | $xaction->setObjectPHID($object->getPHID()); | ||||
if ($xaction->getComment()) { | if ($xaction->getComment()) { | ||||
$xaction->setPHID($xaction->generatePHID()); | $xaction->setPHID($xaction->generatePHID()); | ||||
$comment_editor->applyEdit($xaction, $xaction->getComment()); | $comment_editor->applyEdit($xaction, $xaction->getComment()); | ||||
} else { | } else { | ||||
// TODO: This is a transitional hack to let us migrate edge | // TODO: This is a transitional hack to let us migrate edge | ||||
// transactions to a more efficient storage format. For now, we're | // transactions to a more efficient storage format. For now, we're | ||||
▲ Show 20 Lines • Show All 3,952 Lines • Show Last 20 Lines |