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

Hide direct accesses to Audit inline comment table behind API

Summary: Ref T4896. Move all direct accesses to the inline comment table behind a small amount of API to make it easier to migrate the table.

Test Plan:
- Grepped for `PhabricatorAuditInlineComment`.
- Grepped for `audit_inlinecomment`.
- Created a draft comment.
- Previewed a draft comment.
- Reloaded page, still saw draft.
- Viewed standalone, still saw draft.
- Made comment, inline published.
- Added a draft, saw both.
- Edited inline comment.
- Reindexed commit.
- Searched for unique word in published comment, found commit.
- Searched for unique word in draft comment, no results.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T4896

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

+53 -20
+2 -4
src/applications/audit/editor/PhabricatorAuditCommentEditor.php
··· 46 46 47 47 $inline_comments = array(); 48 48 if ($this->attachInlineComments) { 49 - $inline_comments = id(new PhabricatorAuditInlineComment())->loadAllWhere( 50 - 'authorPHID = %s AND commitPHID = %s 51 - AND auditCommentID IS NULL', 52 - $actor->getPHID(), 49 + $inline_comments = PhabricatorAuditInlineComment::loadDraftComments( 50 + $actor, 53 51 $commit->getPHID()); 54 52 } 55 53
+39
src/applications/audit/storage/PhabricatorAuditInlineComment.php
··· 17 17 18 18 private $syntheticAuthor; 19 19 20 + public static function loadDraftComments( 21 + PhabricatorUser $viewer, 22 + $commit_phid) { 23 + 24 + return id(new PhabricatorAuditInlineComment())->loadAllWhere( 25 + 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL', 26 + $viewer->getPHID(), 27 + $commit_phid); 28 + } 29 + 30 + public static function loadPublishedComments( 31 + PhabricatorUser $viewer, 32 + $commit_phid) { 33 + 34 + return id(new PhabricatorAuditInlineComment())->loadAllWhere( 35 + 'commitPHID = %s AND auditCommentID IS NOT NULL', 36 + $commit_phid); 37 + } 38 + 39 + public static function loadDraftAndPublishedComments( 40 + PhabricatorUser $viewer, 41 + $commit_phid, 42 + $path_id = null) { 43 + 44 + if ($path_id === null) { 45 + return id(new PhabricatorAuditInlineComment())->loadAllWhere( 46 + 'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)', 47 + $commit_phid, 48 + $viewer->getPHID()); 49 + } else { 50 + return id(new PhabricatorAuditInlineComment())->loadAllWhere( 51 + 'commitPHID = %s AND pathID = %d AND 52 + (authorPHID = %s OR auditCommentID IS NOT NULL)', 53 + $commit_phid, 54 + $path_id, 55 + $viewer->getPHID()); 56 + } 57 + } 58 + 20 59 public function setSyntheticAuthor($synthetic_author) { 21 60 $this->syntheticAuthor = $synthetic_author; 22 61 return $this;
+5 -6
src/applications/diffusion/controller/DiffusionCommitController.php
··· 323 323 $visible_changesets = $changesets; 324 324 } else { 325 325 $visible_changesets = array(); 326 - $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( 327 - 'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)', 328 - $commit->getPHID(), 329 - $user->getPHID()); 326 + $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments( 327 + $user, 328 + $commit->getPHID()); 330 329 $path_ids = mpull($inlines, null, 'getPathID'); 331 330 foreach ($changesets as $key => $changeset) { 332 331 if (array_key_exists($changeset->getID(), $path_ids)) { ··· 648 647 'targetPHID = %s ORDER BY dateCreated ASC', 649 648 $commit->getPHID()); 650 649 651 - $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( 652 - 'commitPHID = %s AND auditCommentID IS NOT NULL', 650 + $inlines = PhabricatorAuditInlineComment::loadPublishedComments( 651 + $user, 653 652 $commit->getPHID()); 654 653 655 654 $path_ids = mpull($inlines, 'getPathID');
+3 -5
src/applications/diffusion/controller/DiffusionDiffController.php
··· 86 86 $parser->setWhitespaceMode( 87 87 DifferentialChangesetParser::WHITESPACE_SHOW_ALL); 88 88 89 - $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( 90 - 'commitPHID = %s AND pathID = %d AND 91 - (authorPHID = %s OR auditCommentID IS NOT NULL)', 89 + $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments( 90 + $user, 92 91 $drequest->loadCommit()->getPHID(), 93 - $path_id, 94 - $user->getPHID()); 92 + $path_id); 95 93 96 94 if ($inlines) { 97 95 foreach ($inlines as $inline) {
+2 -3
src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
··· 12 12 protected function loadInlineComments() { 13 13 $user = $this->getRequest()->getUser(); 14 14 15 - $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( 16 - 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL', 17 - $user->getPHID(), 15 + $inlines = PhabricatorAuditInlineComment::loadDraftComments( 16 + $user, 18 17 $this->commitPHID); 19 18 20 19 return $inlines;
+2 -2
src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
··· 77 77 } 78 78 } 79 79 80 - $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere( 81 - 'commitPHID = %s AND (auditCommentID IS NOT NULL)', 80 + $inlines = PhabricatorAuditInlineComment::loadPublishedComments( 81 + $this->getViewer(), 82 82 $commit->getPHID()); 83 83 foreach ($inlines as $inline) { 84 84 if (strlen($inline->getContent())) {