Page MenuHomePhorge

D25558.1736978952.diff
No OneTemporary

D25558.1736978952.diff

diff --git a/src/deepclone/controller/DeepcloneController.php b/src/deepclone/controller/DeepcloneController.php
--- a/src/deepclone/controller/DeepcloneController.php
+++ b/src/deepclone/controller/DeepcloneController.php
@@ -12,9 +12,11 @@
return new Aphront404Response();
}
- $task = id(new ManiphestTaskQuery())
+ $query = new ManiphestTaskQuery();
+ $task = $query
->setViewer($viewer)
->withPHIDs(array($task_id))
+ ->withOpenSubtasks(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -29,8 +31,14 @@
return new Aphront404Response();
}
+ $transactions = id(new ManiphestTransactionQuery())
+ ->setViewer($request->getUser())
+ ->withObjectPHIDs(mpull([$task], 'getPHID'))
+ ->needComments(true)
+ ->execute();
+
if ($request->isFormPost()) {
- return $this->triggerTransaction($request, $task);
+ return $this->triggerTransaction($request, $task, $transactions);
// $properties = $provider->readFormValuesFromRequest($request);
// list($errors, $issues, $properties) = $provider->processEditForm(
// $request,
@@ -178,12 +186,51 @@
return $handle;
}
- private function triggerTransaction(AphrontRequest $request, ManiphestTask $task) {
+ private function triggerTransaction(AphrontRequest $request, ManiphestTask $task, array $transactions) {
$deepCloneRaw = $request->getStr('deep_clone');
$deepClone = $deepCloneRaw === '1';
$copyCommentsRaw = $request->getStr('copy_comments');
$copyComments = $copyCommentsRaw === '1';
- throw new Exception("Deep Clone $deepClone $deepCloneRaw Copy Comments $copyComments $copyCommentsRaw");
+ $taskClone = new ManiphestTask();
+
+ $taskClone->setTitle($task->getTitle());
+ $taskClone->setDescription($task->getDescription());
+ $taskClone->setAuthorPHID($task->getAuthorPHID());
+ $taskClone->setOwnerPHID($task->getOwnerPHID());
+ $taskClone->setStatus($task->getStatus());
+ $taskClone->setPriority($task->getPriority());
+ $taskClone->setSubtype($task->getSubtype());
+ $taskClone->setViewPolicy($task->getViewPolicy());
+ $taskClone->setEditPolicy($task->getEditPolicy());
+
+ $taskClone->save();
+
+ foreach($transactions as &$transaction) {
+ if ($transaction->getTransactionType() !== 'core:comment') {
+ continue;
+ }
+
+ if ($copyComments === false) {
+ continue;
+ }
+
+ $transactionClone = new ManiphestTransaction();
+ $transactionClone->setViewPolicy($transaction->getViewPolicy());
+ $transactionClone->setEditPolicy($transaction->getEditPolicy());
+ $transactionClone->setTransactionType('core:comment');
+ $transactionClone->setObjectPHID($taskClone->getPHID());
+ $transactionClone->setAuthorPHID($transaction->getAuthorPHID());
+ $transactionClone->setContentSource($transaction->getContentSource());
+ $comment = $transaction->getComment()->getContent();
+ $transactionClone->attachComment(
+ id(new ManiphestTransactionComment())
+ ->setContent([$comment])
+ );
+
+ $transactionClone->save();
+ }
+
+ return id(new AphrontRedirectResponse())->setURI($taskClone->getURI());
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 15, 22:09 (3 d, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116352
Default Alt Text
D25558.1736978952.diff (3 KB)

Event Timeline