Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2875370
D25558.1736978952.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
D25558.1736978952.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D25558: Initial work
Attached
Detach File
Event Timeline
Log In to Comment