Make InlineCommentQueries more robust/consistent

Summary:
Ref T13513. Improve consistency and robustness of the "InlineComment" queries.

The only real change here is that these queries now implicitly add a clause for selecting inlines ("pathID IS NULL" or "changesetID IS NULL").

Test Plan: Browed, created, edited, and submitted inlines.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21227
This commit is contained in:
epriestley
2020-05-07 10:46:49 -07:00
parent 1656a2ff08
commit c1f1345cc0
6 changed files with 93 additions and 72 deletions

View File

@@ -6,6 +6,10 @@ abstract class PhabricatorDiffInlineCommentQuery
private $fixedStates;
private $needReplyToComments;
abstract protected function buildInlineCommentWhereClauseParts(
AphrontDatabaseConnection $conn);
abstract public function withObjectPHIDs(array $phids);
public function withFixedStates(array $states) {
$this->fixedStates = $states;
return $this;
@@ -16,14 +20,19 @@ abstract class PhabricatorDiffInlineCommentQuery
return $this;
}
protected function buildWhereClauseComponents(
AphrontDatabaseConnection $conn_r) {
$where = parent::buildWhereClauseComponents($conn_r);
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
$alias = $this->getPrimaryTableAlias();
foreach ($this->buildInlineCommentWhereClauseParts($conn) as $part) {
$where[] = $part;
}
if ($this->fixedStates !== null) {
$where[] = qsprintf(
$conn_r,
'fixedState IN (%Ls)',
$conn,
'%T.fixedState IN (%Ls)',
$alias,
$this->fixedStates);
}