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

Write "hasReplies" to database for inline comments

Summary:
Ref T1460. Ref T2618.

When publishing a draft inline, mark the inline it replies to (if any) as replied to.

Also, don't load deleted comments as drafts (sets the stage for T2618).

I'll make an effort to clean up the loading mess here in the next revision, and find some more appropriate home for the shared code.

Test Plan: Made and replied to comments in Differential and Diffusion. Saw comments get marked as "Has Replies" and "Is Reply".

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2618, T1460

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

+91 -5
+6 -1
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 135 135 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 136 136 case PhabricatorTransactions::TYPE_EDGE: 137 137 case PhabricatorAuditActionConstants::ACTION: 138 + case PhabricatorAuditTransaction::TYPE_COMMIT: 139 + return; 138 140 case PhabricatorAuditActionConstants::INLINE: 139 - case PhabricatorAuditTransaction::TYPE_COMMIT: 141 + $reply = $xaction->getComment()->getReplyToComment(); 142 + if ($reply && !$reply->getHasReplies()) { 143 + $reply->setHasReplies(1)->save(); 144 + } 140 145 return; 141 146 case PhabricatorAuditActionConstants::ADD_AUDITORS: 142 147 $new = $xaction->getNewValue();
+7 -2
src/applications/audit/storage/PhabricatorAuditInlineComment.php
··· 63 63 64 64 $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere( 65 65 'authorPHID = %s AND commitPHID = %s AND transactionPHID IS NULL 66 - AND pathID IS NOT NULL', 66 + AND pathID IS NOT NULL 67 + AND isDeleted = 0', 67 68 $viewer->getPHID(), 68 69 $commit_phid); 70 + 71 + $inlines = PhabricatorInlineCommentController::loadAndAttachReplies( 72 + $viewer, 73 + $inlines); 69 74 70 75 return self::buildProxies($inlines); 71 76 } ··· 96 101 } else { 97 102 $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere( 98 103 'commitPHID = %s AND pathID = %d AND 99 - (authorPHID = %s OR transactionPHID IS NOT NULL)', 104 + ((authorPHID = %s AND isDeleted = 0) OR transactionPHID IS NOT NULL)', 100 105 $commit_phid, 101 106 $path_id, 102 107 $viewer->getPHID());
+12
src/applications/audit/storage/PhabricatorAuditTransactionComment.php
··· 13 13 protected $replyToCommentPHID; 14 14 protected $legacyCommentID; 15 15 16 + private $replyToComment = self::ATTACHABLE; 17 + 16 18 public function getApplicationTransactionObject() { 17 19 return new PhabricatorAuditTransaction(); 18 20 } ··· 53 55 ) + $config[self::CONFIG_KEY_SCHEMA]; 54 56 55 57 return $config; 58 + } 59 + 60 + public function attachReplyToComment( 61 + PhabricatorAuditTransactionComment $comment = null) { 62 + $this->replyToComment = $comment; 63 + return $this; 64 + } 65 + 66 + public function getReplyToComment() { 67 + return $this->assertAttached($this->replyToComment); 56 68 } 57 69 58 70 }
+5
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 534 534 case PhabricatorTransactions::TYPE_EDGE: 535 535 case PhabricatorTransactions::TYPE_COMMENT: 536 536 case DifferentialTransaction::TYPE_ACTION: 537 + return; 537 538 case DifferentialTransaction::TYPE_INLINE: 539 + $reply = $xaction->getComment()->getReplyToComment(); 540 + if ($reply && !$reply->getHasReplies()) { 541 + $reply->setHasReplies(1)->save(); 542 + } 538 543 return; 539 544 case DifferentialTransaction::TYPE_UPDATE: 540 545 // Now that we're inside the transaction, do a final check.
+9 -2
src/applications/differential/query/DifferentialTransactionQuery.php
··· 25 25 'SELECT phid FROM %T 26 26 WHERE revisionPHID = %s 27 27 AND authorPHID = %s 28 - AND transactionPHID IS NULL', 28 + AND transactionPHID IS NULL 29 + AND isDeleted = 0', 29 30 $table->getTableName(), 30 31 $revision->getPHID(), 31 32 $viewer->getPHID()); ··· 35 36 return array(); 36 37 } 37 38 38 - return id(new PhabricatorApplicationTransactionCommentQuery()) 39 + $comments = id(new PhabricatorApplicationTransactionCommentQuery()) 39 40 ->setTemplate(new DifferentialTransactionComment()) 40 41 ->setViewer($viewer) 41 42 ->withPHIDs($phids) 42 43 ->execute(); 44 + 45 + $comments = PhabricatorInlineCommentController::loadAndAttachReplies( 46 + $viewer, 47 + $comments); 48 + 49 + return $comments; 43 50 } 44 51 45 52 }
+12
src/applications/differential/storage/DifferentialTransactionComment.php
··· 12 12 protected $hasReplies = 0; 13 13 protected $replyToCommentPHID; 14 14 15 + private $replyToComment = self::ATTACHABLE; 16 + 15 17 public function getApplicationTransactionObject() { 16 18 return new DifferentialTransaction(); 19 + } 20 + 21 + public function attachReplyToComment( 22 + DifferentialTransactionComment $comment = null) { 23 + $this->replyToComment = $comment; 24 + return $this; 25 + } 26 + 27 + public function getReplyToComment() { 28 + return $this->assertAttached($this->replyToComment); 17 29 } 18 30 19 31 protected function getConfiguration() {
+40
src/infrastructure/diff/PhabricatorInlineCommentController.php
··· 309 309 ->addRowScaffold($view); 310 310 } 311 311 312 + public static function loadAndAttachReplies( 313 + PhabricatorUser $viewer, 314 + array $comments) { 315 + // TODO: This code doesn't really belong here, but we don't have a much 316 + // better place to put it at the moment. 317 + 318 + if (!$comments) { 319 + return $comments; 320 + } 321 + 322 + $template = head($comments); 323 + 324 + $reply_phids = array(); 325 + foreach ($comments as $comment) { 326 + $reply_phid = $comment->getReplyToCommentPHID(); 327 + if ($reply_phid) { 328 + $reply_phids[] = $reply_phid; 329 + } 330 + } 331 + 332 + if ($reply_phids) { 333 + $reply_comments = id(new PhabricatorApplicationTransactionCommentQuery()) 334 + ->setTemplate($template) 335 + ->setViewer($viewer) 336 + ->withPHIDs($reply_phids) 337 + ->execute(); 338 + $reply_comments = mpull($reply_comments, null, 'getPHID'); 339 + } else { 340 + $reply_comments = array(); 341 + } 342 + 343 + foreach ($comments as $comment) { 344 + $reply_phid = $comment->getReplyToCommentPHID(); 345 + $reply = idx($reply_comments, $reply_phid); 346 + $comment->attachReplyToComment($reply); 347 + } 348 + 349 + return $comments; 350 + } 351 + 312 352 }