1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Fix transaction queries using withComments() for transactions with no comments

Summary:
See <https://discourse.phabricator-community.org/t/daemons-tasks-crashing-in-a-loop-during-reindex/506/1>. Some object types (for example, Passphrase Credentials) support indexing but not commenting.

Make `withComments(...)` work properly if the transaction type does not support comments.

Test Plan:
Indexed a credential (no comments) and a revision (comments) with `bin/search index --trace ...`.

Before, credential fataled.

After, credetial succeeds, and skips the transaction query.

Before and after, the revision queries the transaction table.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18667
This commit is contained in:
epriestley 2017-10-02 07:21:38 -07:00
parent 5c73c169fd
commit cd14194a32

View file

@ -203,16 +203,29 @@ abstract class PhabricatorApplicationTransactionQuery
$xaction = $this->getTemplateApplicationTransaction(); $xaction = $this->getTemplateApplicationTransaction();
$comment = $xaction->getApplicationTransactionCommentObject(); $comment = $xaction->getApplicationTransactionCommentObject();
if ($this->withComments) { // Not every transaction type has comments, so we may be able to
$joins[] = qsprintf( // implement this constraint trivially.
$conn,
'JOIN %T c ON x.phid = c.transactionPHID', if (!$comment) {
$comment->getTableName()); if ($this->withComments) {
throw new PhabricatorEmptyQueryException();
} else {
// If we're querying for transactions with no comments and the
// transaction type does not support comments, we don't need to
// do anything.
}
} else { } else {
$joins[] = qsprintf( if ($this->withComments) {
$conn, $joins[] = qsprintf(
'LEFT JOIN %T c ON x.phid = c.transactionPHID', $conn,
$comment->getTableName()); 'JOIN %T c ON x.phid = c.transactionPHID',
$comment->getTableName());
} else {
$joins[] = qsprintf(
$conn,
'LEFT JOIN %T c ON x.phid = c.transactionPHID',
$comment->getTableName());
}
} }
} }