Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15383031
D10016.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D10016.diff
View Options
diff --git a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
--- a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php
@@ -46,10 +46,8 @@
$inline_comments = array();
if ($this->attachInlineComments) {
- $inline_comments = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'authorPHID = %s AND commitPHID = %s
- AND auditCommentID IS NULL',
- $actor->getPHID(),
+ $inline_comments = PhabricatorAuditInlineComment::loadDraftComments(
+ $actor,
$commit->getPHID());
}
diff --git a/src/applications/audit/storage/PhabricatorAuditInlineComment.php b/src/applications/audit/storage/PhabricatorAuditInlineComment.php
--- a/src/applications/audit/storage/PhabricatorAuditInlineComment.php
+++ b/src/applications/audit/storage/PhabricatorAuditInlineComment.php
@@ -17,6 +17,45 @@
private $syntheticAuthor;
+ public static function loadDraftComments(
+ PhabricatorUser $viewer,
+ $commit_phid) {
+
+ return id(new PhabricatorAuditInlineComment())->loadAllWhere(
+ 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL',
+ $viewer->getPHID(),
+ $commit_phid);
+ }
+
+ public static function loadPublishedComments(
+ PhabricatorUser $viewer,
+ $commit_phid) {
+
+ return id(new PhabricatorAuditInlineComment())->loadAllWhere(
+ 'commitPHID = %s AND auditCommentID IS NOT NULL',
+ $commit_phid);
+ }
+
+ public static function loadDraftAndPublishedComments(
+ PhabricatorUser $viewer,
+ $commit_phid,
+ $path_id = null) {
+
+ if ($path_id === null) {
+ return id(new PhabricatorAuditInlineComment())->loadAllWhere(
+ 'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)',
+ $commit_phid,
+ $viewer->getPHID());
+ } else {
+ return id(new PhabricatorAuditInlineComment())->loadAllWhere(
+ 'commitPHID = %s AND pathID = %d AND
+ (authorPHID = %s OR auditCommentID IS NOT NULL)',
+ $commit_phid,
+ $path_id,
+ $viewer->getPHID());
+ }
+ }
+
public function setSyntheticAuthor($synthetic_author) {
$this->syntheticAuthor = $synthetic_author;
return $this;
diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php
--- a/src/applications/diffusion/controller/DiffusionCommitController.php
+++ b/src/applications/diffusion/controller/DiffusionCommitController.php
@@ -323,10 +323,9 @@
$visible_changesets = $changesets;
} else {
$visible_changesets = array();
- $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)',
- $commit->getPHID(),
- $user->getPHID());
+ $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
+ $user,
+ $commit->getPHID());
$path_ids = mpull($inlines, null, 'getPathID');
foreach ($changesets as $key => $changeset) {
if (array_key_exists($changeset->getID(), $path_ids)) {
@@ -648,8 +647,8 @@
'targetPHID = %s ORDER BY dateCreated ASC',
$commit->getPHID());
- $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND auditCommentID IS NOT NULL',
+ $inlines = PhabricatorAuditInlineComment::loadPublishedComments(
+ $user,
$commit->getPHID());
$path_ids = mpull($inlines, 'getPathID');
diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php
--- a/src/applications/diffusion/controller/DiffusionDiffController.php
+++ b/src/applications/diffusion/controller/DiffusionDiffController.php
@@ -86,12 +86,10 @@
$parser->setWhitespaceMode(
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
- $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND pathID = %d AND
- (authorPHID = %s OR auditCommentID IS NOT NULL)',
+ $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
+ $user,
$drequest->loadCommit()->getPHID(),
- $path_id,
- $user->getPHID());
+ $path_id);
if ($inlines) {
foreach ($inlines as $inline) {
diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
--- a/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
+++ b/src/applications/diffusion/controller/DiffusionInlineCommentPreviewController.php
@@ -12,9 +12,8 @@
protected function loadInlineComments() {
$user = $this->getRequest()->getUser();
- $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL',
- $user->getPHID(),
+ $inlines = PhabricatorAuditInlineComment::loadDraftComments(
+ $user,
$this->commitPHID);
return $inlines;
diff --git a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
--- a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
+++ b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
@@ -77,8 +77,8 @@
}
}
- $inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND (auditCommentID IS NOT NULL)',
+ $inlines = PhabricatorAuditInlineComment::loadPublishedComments(
+ $this->getViewer(),
$commit->getPHID());
foreach ($inlines as $inline) {
if (strlen($inline->getContent())) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 3:19 PM (2 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7696650
Default Alt Text
D10016.diff (5 KB)
Attached To
Mode
D10016: Hide direct accesses to Audit inline comment table behind API
Attached
Detach File
Event Timeline
Log In to Comment