mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
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
This commit is contained in:
parent
023dee0d3b
commit
8605a1808d
6 changed files with 53 additions and 20 deletions
|
@ -46,10 +46,8 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
|
||||||
|
|
||||||
$inline_comments = array();
|
$inline_comments = array();
|
||||||
if ($this->attachInlineComments) {
|
if ($this->attachInlineComments) {
|
||||||
$inline_comments = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inline_comments = PhabricatorAuditInlineComment::loadDraftComments(
|
||||||
'authorPHID = %s AND commitPHID = %s
|
$actor,
|
||||||
AND auditCommentID IS NULL',
|
|
||||||
$actor->getPHID(),
|
|
||||||
$commit->getPHID());
|
$commit->getPHID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,45 @@ final class PhabricatorAuditInlineComment
|
||||||
|
|
||||||
private $syntheticAuthor;
|
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) {
|
public function setSyntheticAuthor($synthetic_author) {
|
||||||
$this->syntheticAuthor = $synthetic_author;
|
$this->syntheticAuthor = $synthetic_author;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -323,10 +323,9 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
$visible_changesets = $changesets;
|
$visible_changesets = $changesets;
|
||||||
} else {
|
} else {
|
||||||
$visible_changesets = array();
|
$visible_changesets = array();
|
||||||
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
|
||||||
'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)',
|
$user,
|
||||||
$commit->getPHID(),
|
$commit->getPHID());
|
||||||
$user->getPHID());
|
|
||||||
$path_ids = mpull($inlines, null, 'getPathID');
|
$path_ids = mpull($inlines, null, 'getPathID');
|
||||||
foreach ($changesets as $key => $changeset) {
|
foreach ($changesets as $key => $changeset) {
|
||||||
if (array_key_exists($changeset->getID(), $path_ids)) {
|
if (array_key_exists($changeset->getID(), $path_ids)) {
|
||||||
|
@ -648,8 +647,8 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
'targetPHID = %s ORDER BY dateCreated ASC',
|
'targetPHID = %s ORDER BY dateCreated ASC',
|
||||||
$commit->getPHID());
|
$commit->getPHID());
|
||||||
|
|
||||||
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inlines = PhabricatorAuditInlineComment::loadPublishedComments(
|
||||||
'commitPHID = %s AND auditCommentID IS NOT NULL',
|
$user,
|
||||||
$commit->getPHID());
|
$commit->getPHID());
|
||||||
|
|
||||||
$path_ids = mpull($inlines, 'getPathID');
|
$path_ids = mpull($inlines, 'getPathID');
|
||||||
|
|
|
@ -86,12 +86,10 @@ final class DiffusionDiffController extends DiffusionController {
|
||||||
$parser->setWhitespaceMode(
|
$parser->setWhitespaceMode(
|
||||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||||
|
|
||||||
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments(
|
||||||
'commitPHID = %s AND pathID = %d AND
|
$user,
|
||||||
(authorPHID = %s OR auditCommentID IS NOT NULL)',
|
|
||||||
$drequest->loadCommit()->getPHID(),
|
$drequest->loadCommit()->getPHID(),
|
||||||
$path_id,
|
$path_id);
|
||||||
$user->getPHID());
|
|
||||||
|
|
||||||
if ($inlines) {
|
if ($inlines) {
|
||||||
foreach ($inlines as $inline) {
|
foreach ($inlines as $inline) {
|
||||||
|
|
|
@ -12,9 +12,8 @@ final class DiffusionInlineCommentPreviewController
|
||||||
protected function loadInlineComments() {
|
protected function loadInlineComments() {
|
||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inlines = PhabricatorAuditInlineComment::loadDraftComments(
|
||||||
'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL',
|
$user,
|
||||||
$user->getPHID(),
|
|
||||||
$this->commitPHID);
|
$this->commitPHID);
|
||||||
|
|
||||||
return $inlines;
|
return $inlines;
|
||||||
|
|
|
@ -77,8 +77,8 @@ final class PhabricatorRepositoryCommitSearchIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
|
$inlines = PhabricatorAuditInlineComment::loadPublishedComments(
|
||||||
'commitPHID = %s AND (auditCommentID IS NOT NULL)',
|
$this->getViewer(),
|
||||||
$commit->getPHID());
|
$commit->getPHID());
|
||||||
foreach ($inlines as $inline) {
|
foreach ($inlines as $inline) {
|
||||||
if (strlen($inline->getContent())) {
|
if (strlen($inline->getContent())) {
|
||||||
|
|
Loading…
Reference in a new issue