1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Hide Audit comment table reads behind an API

Summary: Ref T4896. Buries all direct access to the table so we can limit the surface area affected by the migration.

Test Plan:
  - Grepped for `PhabricatorAuditComment`.
  - Grepped for `audit_comment`.
  - Viewed a bunch of comments.
  - Added a comment.
  - Reindexed a commit.
  - Searched for unique term in new comment.

Reviewers: btrahan, joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T4896

Differential Revision: https://secure.phabricator.com/D10019
This commit is contained in:
epriestley 2014-07-24 18:00:07 -07:00
parent c01aa794c1
commit dc5c87f74c
4 changed files with 15 additions and 6 deletions

View file

@ -40,8 +40,8 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
$commit = $this->commit; $commit = $this->commit;
$actor = $this->getActor(); $actor = $this->getActor();
$other_comments = id(new PhabricatorAuditComment())->loadAllWhere( $other_comments = PhabricatorAuditComment::loadComments(
'targetPHID = %s', $actor,
$commit->getPHID()); $commit->getPHID());
$inline_comments = array(); $inline_comments = array();

View file

@ -15,6 +15,15 @@ final class PhabricatorAuditComment extends PhabricatorAuditDAO
protected $content; protected $content;
protected $metadata = array(); protected $metadata = array();
public static function loadComments(
PhabricatorUser $viewer,
$commit_phid) {
return id(new PhabricatorAuditComment())->loadAllWhere(
'targetPHID = %s',
$commit_phid);
}
public function getConfiguration() { public function getConfiguration() {
return array( return array(
self::CONFIG_SERIALIZATION => array( self::CONFIG_SERIALIZATION => array(

View file

@ -643,8 +643,8 @@ final class DiffusionCommitController extends DiffusionController {
private function buildComments(PhabricatorRepositoryCommit $commit) { private function buildComments(PhabricatorRepositoryCommit $commit) {
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$comments = id(new PhabricatorAuditComment())->loadAllWhere( $comments = PhabricatorAuditComment::loadComments(
'targetPHID = %s ORDER BY dateCreated ASC', $user,
$commit->getPHID()); $commit->getPHID());
$inlines = PhabricatorAuditInlineComment::loadPublishedComments( $inlines = PhabricatorAuditInlineComment::loadPublishedComments(

View file

@ -66,8 +66,8 @@ final class PhabricatorRepositoryCommitSearchIndexer
PhabricatorRepositoryRepositoryPHIDType::TYPECONST, PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
$date_created); $date_created);
$comments = id(new PhabricatorAuditComment())->loadAllWhere( $comments = PhabricatorAuditComment::loadComments(
'targetPHID = %s', $this->getViewer(),
$commit->getPHID()); $commit->getPHID());
foreach ($comments as $comment) { foreach ($comments as $comment) {
if (strlen($comment->getContent())) { if (strlen($comment->getContent())) {