mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 10:22:42 +01:00
b3a63a62a2
Summary: It's dumb to execute a query which we know will return an empty result. Test Plan: Looked at comment preview with "11", didn't see "1 = 0" in DarkConsole. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D5177
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationTransactionCommentQuery
|
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
|
|
|
private $template;
|
|
|
|
private $phids;
|
|
private $transactionPHIDs;
|
|
|
|
public function setTemplate(
|
|
PhabricatorApplicationTransactionComment $template) {
|
|
$this->template = $template;
|
|
return $this;
|
|
}
|
|
|
|
public function withPHIDs(array $phids) {
|
|
$this->phids = $phids;
|
|
return $this;
|
|
}
|
|
|
|
public function withTransactionPHIDs(array $transaction_phids) {
|
|
$this->transactionPHIDs = $transaction_phids;
|
|
return $this;
|
|
}
|
|
|
|
protected function loadPage() {
|
|
$table = $this->template;
|
|
$conn_r = $table->establishConnection('r');
|
|
|
|
$data = queryfx_all(
|
|
$conn_r,
|
|
'SELECT * FROM %T xc %Q %Q %Q',
|
|
$table->getTableName(),
|
|
$this->buildWhereClause($conn_r),
|
|
$this->buildOrderClause($conn_r),
|
|
$this->buildLimitClause($conn_r));
|
|
|
|
return $table->loadAllFromArray($data);
|
|
}
|
|
|
|
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
|
$where = array();
|
|
|
|
if ($this->phids) {
|
|
$where[] = qsprintf(
|
|
$conn_r,
|
|
'phid IN (%Ls)',
|
|
$this->phids);
|
|
}
|
|
|
|
if ($this->transactionPHIDs) {
|
|
$where[] = qsprintf(
|
|
$conn_r,
|
|
'transactionPHID IN (%Ls)',
|
|
$this->transactionPHIDs);
|
|
}
|
|
|
|
return $this->formatWhereClause($where);
|
|
}
|
|
|
|
}
|