@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use modern ApplicationTransactions "no effect" stuff in Maniphest

Summary: Fixes T912. This was very nearly working, it just needed a little tweaking on the last mile.

Test Plan:
Made updates with no effect, and updates with an effect. Made a no-effect update and posted just the comment part.

{F129037}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T912

Differential Revision: https://secure.phabricator.com/D8543

+41 -18
+1
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 224 224 $comment_form = new AphrontFormView(); 225 225 $comment_form 226 226 ->setUser($user) 227 + ->setWorkflow(true) 227 228 ->setAction('/maniphest/transaction/save/') 228 229 ->setEncType('multipart/form-data') 229 230 ->addHiddenInput('taskID', $task->getID())
+21 -18
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group maniphest 5 - */ 6 3 final class ManiphestTransactionSaveController extends ManiphestController { 7 4 8 5 public function processRequest() { 9 6 $request = $this->getRequest(); 10 7 $user = $request->getUser(); 11 8 12 - // TODO: T603 This doesn't require CAN_EDIT because non-editors can still 13 - // leave comments, probably? For now, this just nondisruptive. Smooth this 14 - // out once policies are more clear. 15 - 16 9 $task = id(new ManiphestTaskQuery()) 17 10 ->setViewer($user) 18 11 ->withIDs(array($request->getStr('taskID'))) ··· 20 13 if (!$task) { 21 14 return new Aphront404Response(); 22 15 } 16 + 17 + $task_uri = '/'.$task->getMonogram(); 23 18 24 19 $transactions = array(); 25 20 ··· 135 130 $transactions[] = $transaction; 136 131 } 137 132 138 - if ($request->getStr('comments')) { 139 - $transactions[] = id(new ManiphestTransaction()) 140 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 141 - ->attachComment( 142 - id(new ManiphestTransactionComment()) 143 - ->setContent($request->getStr('comments'))); 144 - } 145 - 146 133 // When you interact with a task, we add you to the CC list so you get 147 134 // further updates, and possibly assign the task to you if you took an 148 135 // ownership action (closing it) but it's currently unowned. We also move ··· 208 195 $transactions[] = $cc_transaction; 209 196 } 210 197 198 + $comments = $request->getStr('comments'); 199 + if (strlen($comments) || !$transactions) { 200 + $transactions[] = id(new ManiphestTransaction()) 201 + ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 202 + ->attachComment( 203 + id(new ManiphestTransactionComment()) 204 + ->setContent($comments)); 205 + } 206 + 211 207 $event = new PhabricatorEvent( 212 208 PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, 213 209 array( ··· 226 222 ->setActor($user) 227 223 ->setContentSourceFromRequest($request) 228 224 ->setContinueOnMissingFields(true) 229 - ->applyTransactions($task, $transactions); 225 + ->setContinueOnNoEffect($request->isContinueRequest()); 226 + 227 + try { 228 + $editor->applyTransactions($task, $transactions); 229 + } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 230 + return id(new PhabricatorApplicationTransactionNoEffectResponse()) 231 + ->setCancelURI($task_uri) 232 + ->setException($ex); 233 + } 230 234 231 235 $draft = id(new PhabricatorDraft())->loadOneWhere( 232 236 'authorPHID = %s AND draftKey = %s', ··· 247 251 $event->setAphrontRequest($request); 248 252 PhutilEventEngine::dispatchEvent($event); 249 253 250 - return id(new AphrontRedirectResponse()) 251 - ->setURI('/T'.$task->getID()); 254 + return id(new AphrontRedirectResponse())->setURI($task_uri); 252 255 } 253 256 254 257 }
+4
src/applications/maniphest/storage/ManiphestTask.php
··· 119 119 return $this; 120 120 } 121 121 122 + public function getMonogram() { 123 + return 'T'.$this->getID(); 124 + } 125 + 122 126 public function attachGroupByProjectPHID($phid) { 123 127 $this->groupByProjectPHID = $phid; 124 128 return $this;
+15
src/applications/maniphest/storage/ManiphestTransaction.php
··· 709 709 return $tags; 710 710 } 711 711 712 + public function getNoEffectDescription() { 713 + 714 + switch ($this->getTransactionType()) { 715 + case self::TYPE_STATUS: 716 + return pht('The task already has the selected status.'); 717 + case self::TYPE_OWNER: 718 + return pht('The task already has the selected owner.'); 719 + case self::TYPE_PROJECTS: 720 + return pht('The task is already associated with those projects.'); 721 + case self::TYPE_PRIORITY: 722 + return pht('The task already has the selected priority.'); 723 + } 724 + 725 + return parent::getNoEffectDescription(); 726 + } 712 727 713 728 }