@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.

Route Maniphest comments/detail edits through new code

Summary: Ref T2217. When you add comments (or use that interface to make updates), ship it through the new code.

Test Plan: Added comments, made other changes to Maniphest tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

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

+36 -37
+11 -9
src/applications/maniphest/controller/ManiphestTransactionPreviewController.php
··· 78 78 case ManiphestTransactionType::TYPE_PROJECTS: 79 79 if ($value) { 80 80 $value = json_decode($value); 81 - $phids = $value; 82 - foreach ($task->getProjectPHIDs() as $project_phid) { 83 - $phids[] = $project_phid; 84 - $value[] = $project_phid; 85 - } 86 - $transaction->setNewValue($value); 87 - } else { 88 - $phids = array(); 89 - $transaction->setNewValue(array()); 90 81 } 82 + if (!$value) { 83 + $value = array(); 84 + } 85 + 86 + $phids = $value; 87 + foreach ($task->getProjectPHIDs() as $project_phid) { 88 + $phids[] = $project_phid; 89 + $value[] = $project_phid; 90 + } 91 + 91 92 $transaction->setOldValue($task->getProjectPHIDs()); 93 + $transaction->setNewValue($value); 92 94 break; 93 95 default: 94 96 $phids = array();
+16 -25
src/applications/maniphest/controller/ManiphestTransactionSaveController.php
··· 59 59 } 60 60 $new[PhabricatorFilePHIDTypeFile::TYPECONST][$phid] = array(); 61 61 } 62 - $transaction = new ManiphestTransaction(); 62 + $transaction = new ManiphestTransactionPro(); 63 63 $transaction 64 - ->setAuthorPHID($user->getPHID()) 65 64 ->setTransactionType(ManiphestTransactionType::TYPE_ATTACH); 66 65 $transaction->setNewValue($new); 67 66 $transactions[] = $transaction; ··· 77 76 $request->getStr('comments'), 78 77 )); 79 78 80 - $cc_transaction = new ManiphestTransaction(); 79 + $cc_transaction = new ManiphestTransactionPro(); 81 80 $cc_transaction 82 - ->setAuthorPHID($user->getPHID()) 83 81 ->setTransactionType(ManiphestTransactionType::TYPE_CCS); 84 82 $force_cc_transaction = false; 85 83 86 - $transaction = new ManiphestTransaction(); 84 + $transaction = new ManiphestTransactionPro(); 87 85 $transaction 88 - ->setAuthorPHID($user->getPHID()) 89 86 ->setTransactionType($action); 90 87 91 88 switch ($action) { ··· 139 136 } 140 137 141 138 if ($request->getStr('comments')) { 142 - $transactions[] = id(new ManiphestTransaction()) 143 - ->setAuthorPHID($user->getPHID()) 139 + $transactions[] = id(new ManiphestTransactionPro()) 144 140 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 145 - ->setComments($request->getStr('comments')); 141 + ->attachComment( 142 + id(new ManiphestTransactionComment()) 143 + ->setContent($request->getStr('comments'))); 146 144 } 147 145 148 146 // When you interact with a task, we add you to the CC list so you get ··· 168 166 // Closing an unassigned task. Assign the user as the owner of 169 167 // this task. 170 168 $assign = new ManiphestTransaction(); 171 - $assign->setAuthorPHID($user->getPHID()); 172 169 $assign->setTransactionType(ManiphestTransactionType::TYPE_OWNER); 173 170 $assign->setNewValue($user->getPHID()); 174 171 $transactions[] = $assign; ··· 194 191 195 192 if (!$user_owns_task) { 196 193 // If we aren't making the user the new task owner and they aren't the 197 - // existing task owner, add them to CC. 198 - $added_ccs[] = $user->getPHID(); 194 + // existing task owner, add them to CC unless they're aleady CC'd. 195 + if (!in_array($user->getPHID(), $task->getCCPHIDs())) { 196 + $added_ccs[] = $user->getPHID(); 197 + } 199 198 } 200 199 201 200 if ($added_ccs || $force_cc_transaction) { ··· 207 206 $transactions[] = $cc_transaction; 208 207 } 209 208 210 - $content_source = PhabricatorContentSource::newForSource( 211 - PhabricatorContentSource::SOURCE_WEB, 212 - array( 213 - 'ip' => $request->getRemoteAddr(), 214 - )); 215 - 216 - foreach ($transactions as $transaction) { 217 - $transaction->setContentSource($content_source); 218 - } 219 - 220 209 $event = new PhabricatorEvent( 221 210 PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, 222 211 array( ··· 231 220 $task = $event->getValue('task'); 232 221 $transactions = $event->getValue('transactions'); 233 222 234 - $editor = new ManiphestTransactionEditor(); 235 - $editor->setActor($user); 236 - $editor->applyTransactions($task, $transactions); 223 + $editor = id(new ManiphestTransactionEditorPro()) 224 + ->setActor($user) 225 + ->setContentSourceFromRequest($request) 226 + ->setContinueOnMissingFields(true) 227 + ->applyTransactions($task, $transactions); 237 228 238 229 $draft = id(new PhabricatorDraft())->loadOneWhere( 239 230 'authorPHID = %s AND draftKey = %s',
+3 -2
src/applications/maniphest/editor/ManiphestTransactionEditorPro.php
··· 36 36 case ManiphestTransactionPro::TYPE_OWNER: 37 37 return $object->getOwnerPHID(); 38 38 case ManiphestTransactionPro::TYPE_CCS: 39 - return $object->getCCPHIDs(); 39 + return array_values(array_unique($object->getCCPHIDs())); 40 40 case ManiphestTransactionPro::TYPE_PROJECTS: 41 41 return $object->getProjectPHIDs(); 42 42 case ManiphestTransactionPro::TYPE_ATTACH: ··· 56 56 case ManiphestTransactionPro::TYPE_PRIORITY: 57 57 case ManiphestTransactionPro::TYPE_STATUS: 58 58 return (int)$xaction->getNewValue(); 59 + case ManiphestTransactionPro::TYPE_CCS: 60 + return array_values(array_unique($xaction->getNewValue())); 59 61 case ManiphestTransactionPro::TYPE_TITLE: 60 62 case ManiphestTransactionPro::TYPE_DESCRIPTION: 61 63 case ManiphestTransactionPro::TYPE_OWNER: 62 - case ManiphestTransactionPro::TYPE_CCS: 63 64 case ManiphestTransactionPro::TYPE_PROJECTS: 64 65 case ManiphestTransactionPro::TYPE_ATTACH: 65 66 case ManiphestTransactionPro::TYPE_EDGE:
+6 -1
src/applications/maniphest/storage/ManiphestTransactionPro.php
··· 306 306 $this->renderHandleLink($author_phid), 307 307 count($removed), 308 308 $this->renderHandleList($removed)); 309 - } else { 309 + } else if ($removed && $added) { 310 310 return pht( 311 311 '%s changed projects, added %d: %s; removed %d: %s', 312 312 $this->renderHandleLink($author_phid), ··· 314 314 $this->renderHandleList($added), 315 315 count($removed), 316 316 $this->renderHandleList($removed)); 317 + } else { 318 + // This is hit when rendering previews. 319 + return pht( 320 + '%s changed projects...', 321 + $this->renderHandleLink($author_phid)); 317 322 } 318 323 319 324 case self::TYPE_PRIORITY: