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

Provide some more detailed information about inline comments in "transaction.search"

Summary:
Ref T5873. This provides paths and line numbers for inline comments.

This is a touch hacky but I was able to keep it mostly under control.

Test Plan:
- Made inline comments.
- Called API, got path/line information.

{F5120157}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5873

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

+77 -1
+2
src/__phutil_library_map__.php
··· 544 544 'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php', 545 545 'DifferentialRevisionHeraldFieldGroup' => 'applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php', 546 546 'DifferentialRevisionIDCommitMessageField' => 'applications/differential/field/DifferentialRevisionIDCommitMessageField.php', 547 + 'DifferentialRevisionInlineTransaction' => 'applications/differential/xaction/DifferentialRevisionInlineTransaction.php', 547 548 'DifferentialRevisionInlinesController' => 'applications/differential/controller/DifferentialRevisionInlinesController.php', 548 549 'DifferentialRevisionListController' => 'applications/differential/controller/DifferentialRevisionListController.php', 549 550 'DifferentialRevisionListView' => 'applications/differential/view/DifferentialRevisionListView.php', ··· 5547 5548 'DifferentialRevisionHeraldField' => 'HeraldField', 5548 5549 'DifferentialRevisionHeraldFieldGroup' => 'HeraldFieldGroup', 5549 5550 'DifferentialRevisionIDCommitMessageField' => 'DifferentialCommitMessageField', 5551 + 'DifferentialRevisionInlineTransaction' => 'PhabricatorModularTransactionType', 5550 5552 'DifferentialRevisionInlinesController' => 'DifferentialController', 5551 5553 'DifferentialRevisionListController' => 'DifferentialController', 5552 5554 'DifferentialRevisionListView' => 'AphrontView',
+53
src/applications/differential/xaction/DifferentialRevisionInlineTransaction.php
··· 1 + <?php 2 + 3 + final class DifferentialRevisionInlineTransaction 4 + extends PhabricatorModularTransactionType { 5 + 6 + // NOTE: This class is NOT an actual Differential modular transaction type! 7 + // It does not extend "DifferentialRevisionTransactionType". Some day it 8 + // should, but for now it's just reducing the amount of hackiness around 9 + // supporting inline comments in the "transaction.search" Conduit API method. 10 + 11 + const TRANSACTIONTYPE = 'internal.pretend-inline'; 12 + 13 + public function getTransactionTypeForConduit($xaction) { 14 + return 'inline'; 15 + } 16 + 17 + public function loadTransactionTypeConduitData(array $xactions) { 18 + $viewer = $this->getViewer(); 19 + 20 + $changeset_ids = array(); 21 + foreach ($xactions as $xaction) { 22 + $changeset_ids[] = $xaction->getComment()->getChangesetID(); 23 + } 24 + 25 + $changesets = id(new DifferentialChangesetQuery()) 26 + ->setViewer($viewer) 27 + ->withIDs($changeset_ids) 28 + ->execute(); 29 + 30 + $changesets = mpull($changesets, null, 'getID'); 31 + 32 + return $changesets; 33 + } 34 + 35 + public function getFieldValuesForConduit($object, $data) { 36 + $comment = $object->getComment(); 37 + 38 + $changeset = $data[$comment->getChangesetID()]; 39 + $diff = $changeset->getDiff(); 40 + 41 + return array( 42 + 'diff' => array( 43 + 'id' => $diff->getID(), 44 + 'phid' => $diff->getPHID(), 45 + ), 46 + 'path' => $changeset->getDisplayFilename(), 47 + 'line' => (int)$comment->getLineNumber(), 48 + 'length' => (int)($comment->getLineLength() + 1), 49 + 'replyToCommentPHID' => $comment->getReplyToCommentPHID(), 50 + ); 51 + } 52 + 53 + }
+22 -1
src/applications/transactions/conduit/TransactionSearchConduitAPIMethod.php
··· 97 97 continue; 98 98 } 99 99 100 - $modular_template = $xaction->getModularType(); 100 + // TODO: Hack things so certain transactions which don't have a modular 101 + // type yet can use a pseudotype until they modularize. Some day, we'll 102 + // modularize everything and remove this. 103 + switch ($xaction->getTransactionType()) { 104 + case DifferentialTransaction::TYPE_INLINE: 105 + $modular_template = new DifferentialRevisionInlineTransaction(); 106 + break; 107 + default: 108 + $modular_template = $xaction->getModularType(); 109 + break; 110 + } 111 + 101 112 $modular_class = get_class($modular_template); 102 113 if (!isset($modular_objects[$modular_class])) { 103 114 try { ··· 171 182 172 183 if (!$fields) { 173 184 $fields = (object)$fields; 185 + } 186 + 187 + // If we haven't found a modular type, fallback for some simple core 188 + // types. Ideally, we'll modularize everything some day. 189 + if ($type === null) { 190 + switch ($xaction->getTransactionType()) { 191 + case PhabricatorTransactions::TYPE_COMMENT: 192 + $type = 'comment'; 193 + break; 194 + } 174 195 } 175 196 176 197 $data[] = array(