1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 07:11:04 +01:00

Update many Phabricator queries for new %Q query semantics

Summary: Depends on D19785. Ref T13217. This converts many of the most common clause construction pathways to the new %Q / %LQ / %LO / %LA / %LJ semantics.

Test Plan: Browsed around a bunch, saw fewer warnings and no obvious behavioral errors. The transformations here are generally mechanical (although I did them by hand).

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: hach-que

Maniphest Tasks: T13217

Differential Revision: https://secure.phabricator.com/D19789
This commit is contained in:
epriestley 2018-11-07 02:48:26 -08:00
parent 64b52b9952
commit 98690ee326
54 changed files with 407 additions and 417 deletions

View file

@ -59,26 +59,26 @@ final class PhabricatorAuthInviteQuery
return $invites; return $invites;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->emailAddresses !== null) { if ($this->emailAddresses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'emailAddress IN (%Ls)', 'emailAddress IN (%Ls)',
$this->emailAddresses); $this->emailAddresses);
} }
@ -90,21 +90,21 @@ final class PhabricatorAuthInviteQuery
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'verificationHash IN (%Ls)', 'verificationHash IN (%Ls)',
$hashes); $hashes);
} }
if ($this->authorPHIDs !== null) { if ($this->authorPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'authorPHID IN (%Ls)', 'authorPHID IN (%Ls)',
$this->authorPHIDs); $this->authorPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -54,26 +54,26 @@ final class PhabricatorAuthProviderConfigQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->providerClasses) { if ($this->providerClasses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'providerClass IN (%Ls)', 'providerClass IN (%Ls)',
$this->providerClasses); $this->providerClasses);
} }
@ -84,16 +84,16 @@ final class PhabricatorAuthProviderConfigQuery
break; break;
case self::STATUS_ENABLED: case self::STATUS_ENABLED:
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isEnabled = 1'); 'isEnabled = 1');
break; break;
default: default:
throw new Exception(pht("Unknown status '%s'!", $status)); throw new Exception(pht("Unknown status '%s'!", $status));
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -65,44 +65,44 @@ final class PhabricatorAuthSessionQuery
return $sessions; return $sessions;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->identityPHIDs) { if ($this->identityPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'userPHID IN (%Ls)', 'userPHID IN (%Ls)',
$this->identityPHIDs); $this->identityPHIDs);
} }
if ($this->sessionKeys) { if ($this->sessionKeys !== null) {
$hashes = array(); $hashes = array();
foreach ($this->sessionKeys as $session_key) { foreach ($this->sessionKeys as $session_key) {
$hashes[] = PhabricatorHash::weakDigest($session_key); $hashes[] = PhabricatorHash::weakDigest($session_key);
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'sessionKey IN (%Ls)', 'sessionKey IN (%Ls)',
$hashes); $hashes);
} }
if ($this->sessionTypes) { if ($this->sessionTypes !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'type IN (%Ls)', 'type IN (%Ls)',
$this->sessionTypes); $this->sessionTypes);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -49,47 +49,47 @@ final class PhabricatorCalendarEventInviteeQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->eventPHIDs !== null) { if ($this->eventPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'eventPHID IN (%Ls)', 'eventPHID IN (%Ls)',
$this->eventPHIDs); $this->eventPHIDs);
} }
if ($this->inviteePHIDs !== null) { if ($this->inviteePHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'inviteePHID IN (%Ls)', 'inviteePHID IN (%Ls)',
$this->inviteePHIDs); $this->inviteePHIDs);
} }
if ($this->inviterPHIDs !== null) { if ($this->inviterPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'inviterPHID IN (%Ls)', 'inviterPHID IN (%Ls)',
$this->inviterPHIDs); $this->inviterPHIDs);
} }
if ($this->statuses !== null) { if ($this->statuses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'status = %d', 'status = %d',
$this->statuses); $this->statuses);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -509,10 +509,6 @@ final class PhabricatorCalendarEventQuery
return parent::shouldGroupQueryResultRows(); return parent::shouldGroupQueryResultRows();
} }
protected function getApplicationSearchObjectPHIDColumn() {
return 'event.phid';
}
public function getQueryApplicationClass() { public function getQueryApplicationClass() {
return 'PhabricatorCalendarApplication'; return 'PhabricatorCalendarApplication';
} }

View file

@ -33,14 +33,14 @@ final class PhabricatorChatLogChannelQuery
return $logs; return $logs;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
if ($this->channelIDs) { if ($this->channelIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->channelIDs); $this->channelIDs);
@ -48,12 +48,12 @@ final class PhabricatorChatLogChannelQuery
if ($this->channels) { if ($this->channels) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'channelName IN (%Ls)', 'channelName IN (%Ls)',
$this->channels); $this->channels);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -55,26 +55,26 @@ final class PhabricatorChatLogQuery
return $events; return $events;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
if ($this->maximumEpoch) { if ($this->maximumEpoch !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'epoch <= %d', 'epoch <= %d',
$this->maximumEpoch); $this->maximumEpoch);
} }
if ($this->channelIDs) { if ($this->channelIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'channelID IN (%Ld)', 'channelID IN (%Ld)',
$this->channelIDs); $this->channelIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -31,26 +31,26 @@ final class PhabricatorConfigEntryQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -38,19 +38,19 @@ final class ConpherenceFulltextQuery
return $rows; return $rows;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->threadPHIDs !== null) { if ($this->threadPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'i.threadPHID IN (%Ls)', 'i.threadPHID IN (%Ls)',
$this->threadPHIDs); $this->threadPHIDs);
} }
if ($this->previousTransactionPHIDs !== null) { if ($this->previousTransactionPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'i.previousTransactionPHID IN (%Ls)', 'i.previousTransactionPHID IN (%Ls)',
$this->previousTransactionPHIDs); $this->previousTransactionPHIDs);
} }
@ -61,12 +61,12 @@ final class ConpherenceFulltextQuery
$compiled_query = $compiler->compileQuery($tokens); $compiled_query = $compiler->compileQuery($tokens);
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)', 'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)',
$compiled_query); $compiled_query);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildOrderByClause(AphrontDatabaseConnection $conn_r) { private function buildOrderByClause(AphrontDatabaseConnection $conn_r) {

View file

@ -57,7 +57,7 @@ final class ConpherenceParticipantCountQuery
} }
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildGroupByClause(AphrontDatabaseConnection $conn) { private function buildGroupByClause(AphrontDatabaseConnection $conn) {

View file

@ -38,7 +38,7 @@ final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery {
$this->participantPHIDs); $this->participantPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildOrderClause(AphrontDatabaseConnection $conn) { private function buildOrderClause(AphrontDatabaseConnection $conn) {

View file

@ -124,46 +124,47 @@ final class PhabricatorDaemonLogQuery
return $daemons; return $daemons;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->notIDs !== null) { if ($this->notIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id NOT IN (%Ld)', 'id NOT IN (%Ld)',
$this->notIDs); $this->notIDs);
} }
if ($this->getStatusConstants()) { if ($this->getStatusConstants()) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'status IN (%Ls)', 'status IN (%Ls)',
$this->getStatusConstants()); $this->getStatusConstants());
} }
if ($this->daemonClasses !== null) { if ($this->daemonClasses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'daemon IN (%Ls)', 'daemon IN (%Ls)',
$this->daemonClasses); $this->daemonClasses);
} }
if ($this->daemonIDs !== null) { if ($this->daemonIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'daemonID IN (%Ls)', 'daemonID IN (%Ls)',
$this->daemonIDs); $this->daemonIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
} }
private function getStatusConstants() { private function getStatusConstants() {

View file

@ -107,31 +107,31 @@ final class DifferentialInlineCommentQuery
return head($this->execute()); return head($this->execute());
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
// Only find inline comments. // Only find inline comments.
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'changesetID IS NOT NULL'); 'changesetID IS NOT NULL');
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->revisionPHIDs !== null) { if ($this->revisionPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'revisionPHID IN (%Ls)', 'revisionPHID IN (%Ls)',
$this->revisionPHIDs); $this->revisionPHIDs);
} }
@ -139,28 +139,28 @@ final class DifferentialInlineCommentQuery
if ($this->drafts === null) { if ($this->drafts === null) {
if ($this->deletedDrafts) { if ($this->deletedDrafts) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'(authorPHID = %s) OR (transactionPHID IS NOT NULL)', '(authorPHID = %s) OR (transactionPHID IS NOT NULL)',
$this->getViewer()->getPHID()); $this->getViewer()->getPHID());
} else { } else {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'(authorPHID = %s AND isDeleted = 0) '(authorPHID = %s AND isDeleted = 0)
OR (transactionPHID IS NOT NULL)', OR (transactionPHID IS NOT NULL)',
$this->getViewer()->getPHID()); $this->getViewer()->getPHID());
} }
} else if ($this->drafts) { } else if ($this->drafts) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'(authorPHID = %s AND isDeleted = 0) AND (transactionPHID IS NULL)', '(authorPHID = %s AND isDeleted = 0) AND (transactionPHID IS NULL)',
$this->getViewer()->getPHID()); $this->getViewer()->getPHID());
} else { } else {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'transactionPHID IS NOT NULL'); 'transactionPHID IS NOT NULL');
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function adjustInlinesForChangesets( public function adjustInlinesForChangesets(

View file

@ -542,26 +542,26 @@ final class DifferentialRevisionQuery
/** /**
* @task internal * @task internal
*/ */
private function buildJoinsClause($conn_r) { private function buildJoinsClause(AphrontDatabaseConnection $conn) {
$joins = array(); $joins = array();
if ($this->pathIDs) { if ($this->pathIDs) {
$path_table = new DifferentialAffectedPath(); $path_table = new DifferentialAffectedPath();
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T p ON p.revisionID = r.id', 'JOIN %T p ON p.revisionID = r.id',
$path_table->getTableName()); $path_table->getTableName());
} }
if ($this->commitHashes) { if ($this->commitHashes) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T hash_rel ON hash_rel.revisionID = r.id', 'JOIN %T hash_rel ON hash_rel.revisionID = r.id',
ArcanistDifferentialRevisionHash::TABLE_NAME); ArcanistDifferentialRevisionHash::TABLE_NAME);
} }
if ($this->ccs) { if ($this->ccs) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T e_ccs ON e_ccs.src = r.phid '. 'JOIN %T e_ccs ON e_ccs.src = r.phid '.
'AND e_ccs.type = %s '. 'AND e_ccs.type = %s '.
'AND e_ccs.dst in (%Ls)', 'AND e_ccs.dst in (%Ls)',
@ -572,7 +572,7 @@ final class DifferentialRevisionQuery
if ($this->reviewers) { if ($this->reviewers) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T reviewer ON reviewer.revisionPHID = r.phid 'JOIN %T reviewer ON reviewer.revisionPHID = r.phid
AND reviewer.reviewerStatus != %s AND reviewer.reviewerStatus != %s
AND reviewer.reviewerPHID in (%Ls)', AND reviewer.reviewerPHID in (%Ls)',
@ -583,7 +583,7 @@ final class DifferentialRevisionQuery
if ($this->draftAuthors) { if ($this->draftAuthors) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T has_draft ON has_draft.srcPHID = r.phid 'JOIN %T has_draft ON has_draft.srcPHID = r.phid
AND has_draft.type = %s AND has_draft.type = %s
AND has_draft.dstPHID IN (%Ls)', AND has_draft.dstPHID IN (%Ls)',
@ -594,21 +594,21 @@ final class DifferentialRevisionQuery
if ($this->commitPHIDs) { if ($this->commitPHIDs) {
$joins[] = qsprintf( $joins[] = qsprintf(
$conn_r, $conn,
'JOIN %T commits ON commits.revisionID = r.id', 'JOIN %T commits ON commits.revisionID = r.id',
DifferentialRevision::TABLE_COMMIT); DifferentialRevision::TABLE_COMMIT);
} }
$joins[] = $this->buildJoinClauseParts($conn_r); $joins[] = $this->buildJoinClauseParts($conn);
return $this->formatJoinClause($joins); return $this->formatJoinClause($conn, $joins);
} }
/** /**
* @task internal * @task internal
*/ */
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->pathIDs) { if ($this->pathIDs) {
@ -616,32 +616,32 @@ final class DifferentialRevisionQuery
$repo_info = igroup($this->pathIDs, 'repositoryID'); $repo_info = igroup($this->pathIDs, 'repositoryID');
foreach ($repo_info as $repository_id => $paths) { foreach ($repo_info as $repository_id => $paths) {
$path_clauses[] = qsprintf( $path_clauses[] = qsprintf(
$conn_r, $conn,
'(p.repositoryID = %d AND p.pathID IN (%Ld))', '(p.repositoryID = %d AND p.pathID IN (%Ld))',
$repository_id, $repository_id,
ipull($paths, 'pathID')); ipull($paths, 'pathID'));
} }
$path_clauses = '('.implode(' OR ', $path_clauses).')'; $path_clauses = qsprintf($conn, '%LO', $path_clauses);
$where[] = $path_clauses; $where[] = $path_clauses;
} }
if ($this->authors) { if ($this->authors) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.authorPHID IN (%Ls)', 'r.authorPHID IN (%Ls)',
$this->authors); $this->authors);
} }
if ($this->revIDs) { if ($this->revIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.id IN (%Ld)', 'r.id IN (%Ld)',
$this->revIDs); $this->revIDs);
} }
if ($this->repositoryPHIDs) { if ($this->repositoryPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.repositoryPHID IN (%Ls)', 'r.repositoryPHID IN (%Ls)',
$this->repositoryPHIDs); $this->repositoryPHIDs);
} }
@ -651,67 +651,67 @@ final class DifferentialRevisionQuery
foreach ($this->commitHashes as $info) { foreach ($this->commitHashes as $info) {
list($type, $hash) = $info; list($type, $hash) = $info;
$hash_clauses[] = qsprintf( $hash_clauses[] = qsprintf(
$conn_r, $conn,
'(hash_rel.type = %s AND hash_rel.hash = %s)', '(hash_rel.type = %s AND hash_rel.hash = %s)',
$type, $type,
$hash); $hash);
} }
$hash_clauses = '('.implode(' OR ', $hash_clauses).')'; $hash_clauses = qsprintf($conn, '%LO', $hash_clauses);
$where[] = $hash_clauses; $where[] = $hash_clauses;
} }
if ($this->commitPHIDs) { if ($this->commitPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'commits.commitPHID IN (%Ls)', 'commits.commitPHID IN (%Ls)',
$this->commitPHIDs); $this->commitPHIDs);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.phid IN (%Ls)', 'r.phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->branches) { if ($this->branches) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.branchName in (%Ls)', 'r.branchName in (%Ls)',
$this->branches); $this->branches);
} }
if ($this->updatedEpochMin !== null) { if ($this->updatedEpochMin !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.dateModified >= %d', 'r.dateModified >= %d',
$this->updatedEpochMin); $this->updatedEpochMin);
} }
if ($this->updatedEpochMax !== null) { if ($this->updatedEpochMax !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.dateModified <= %d', 'r.dateModified <= %d',
$this->updatedEpochMax); $this->updatedEpochMax);
} }
if ($this->createdEpochMin !== null) { if ($this->createdEpochMin !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.dateCreated >= %d', 'r.dateCreated >= %d',
$this->createdEpochMin); $this->createdEpochMin);
} }
if ($this->createdEpochMax !== null) { if ($this->createdEpochMax !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.dateCreated <= %d', 'r.dateCreated <= %d',
$this->createdEpochMax); $this->createdEpochMax);
} }
if ($this->statuses !== null) { if ($this->statuses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.status in (%Ls)', 'r.status in (%Ls)',
$this->statuses); $this->statuses);
} }
@ -725,13 +725,14 @@ final class DifferentialRevisionQuery
DifferentialLegacyQuery::STATUS_CLOSED); DifferentialLegacyQuery::STATUS_CLOSED);
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'r.status in (%Ls)', 'r.status in (%Ls)',
$statuses); $statuses);
} }
$where[] = $this->buildWhereClauseParts($conn_r); $where[] = $this->buildWhereClauseParts($conn);
return $this->formatWhereClause($where);
return $this->formatWhereClause($conn, $where);
} }

View file

@ -70,7 +70,7 @@ final class DiffusionLintCountQuery extends PhabricatorQuery {
} }
protected function buildCustomWhereClause( protected function buildCustomWhereClause(
AphrontDatabaseConnection $conn_r, AphrontDatabaseConnection $conn,
$part) { $part) {
$where = array(); $where = array();
@ -79,19 +79,19 @@ final class DiffusionLintCountQuery extends PhabricatorQuery {
if ($this->codes !== null) { if ($this->codes !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'code IN (%Ls)', 'code IN (%Ls)',
$this->codes); $this->codes);
} }
if ($this->branchIDs !== null) { if ($this->branchIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'branchID IN (%Ld)', 'branchID IN (%Ld)',
$this->branchIDs); $this->branchIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function processPaths() { private function processPaths() {

View file

@ -192,52 +192,52 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery {
/** /**
* @task internal * @task internal
*/ */
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if (isset($this->context)) { if (isset($this->context)) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'symbolContext = %s', 'symbolContext = %s',
$this->context); $this->context);
} }
if ($this->name) { if ($this->name) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'symbolName = %s', 'symbolName = %s',
$this->name); $this->name);
} }
if ($this->namePrefix) { if ($this->namePrefix) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'symbolName LIKE %>', 'symbolName LIKE %>',
$this->namePrefix); $this->namePrefix);
} }
if ($this->repositoryPHIDs) { if ($this->repositoryPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'repositoryPHID IN (%Ls)', 'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs); $this->repositoryPHIDs);
} }
if ($this->language) { if ($this->language) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'symbolLanguage = %s', 'symbolLanguage = %s',
$this->language); $this->language);
} }
if ($this->type) { if ($this->type) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'symbolType = %s', 'symbolType = %s',
$this->type); $this->type);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }

View file

@ -299,40 +299,40 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $atoms; return $atoms;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->bookPHIDs) { if ($this->bookPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'bookPHID IN (%Ls)', 'bookPHID IN (%Ls)',
$this->bookPHIDs); $this->bookPHIDs);
} }
if ($this->types) { if ($this->types) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'type IN (%Ls)', 'type IN (%Ls)',
$this->types); $this->types);
} }
if ($this->names) { if ($this->names) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'name IN (%Ls)', 'name IN (%Ls)',
$this->names); $this->names);
} }
@ -347,7 +347,7 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
} }
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'titleSlugHash in (%Ls)', 'titleSlugHash in (%Ls)',
$hashes); $hashes);
} }
@ -366,46 +366,46 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
if ($contexts && $with_null) { if ($contexts && $with_null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'context IN (%Ls) OR context IS NULL', 'context IN (%Ls) OR context IS NULL',
$contexts); $contexts);
} else if ($contexts) { } else if ($contexts) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'context IN (%Ls)', 'context IN (%Ls)',
$contexts); $contexts);
} else if ($with_null) { } else if ($with_null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'context IS NULL'); 'context IS NULL');
} }
} }
if ($this->indexes) { if ($this->indexes) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'atomIndex IN (%Ld)', 'atomIndex IN (%Ld)',
$this->indexes); $this->indexes);
} }
if ($this->isDocumentable !== null) { if ($this->isDocumentable !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isDocumentable = %d', 'isDocumentable = %d',
(int)$this->isDocumentable); (int)$this->isDocumentable);
} }
if ($this->isGhost !== null) { if ($this->isGhost !== null) {
if ($this->isGhost) { if ($this->isGhost) {
$where[] = qsprintf($conn_r, 'graphHash IS NULL'); $where[] = qsprintf($conn, 'graphHash IS NULL');
} else { } else {
$where[] = qsprintf($conn_r, 'graphHash IS NOT NULL'); $where[] = qsprintf($conn, 'graphHash IS NOT NULL');
} }
} }
if ($this->nodeHashes) { if ($this->nodeHashes) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'nodeHash IN (%Ls)', 'nodeHash IN (%Ls)',
$this->nodeHashes); $this->nodeHashes);
} }
@ -415,21 +415,21 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
// the column has binary collation. Eventually, this should move into // the column has binary collation. Eventually, this should move into
// fulltext. // fulltext.
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'CONVERT(name USING utf8) LIKE %~', 'CONVERT(name USING utf8) LIKE %~',
$this->nameContains); $this->nameContains);
} }
if ($this->repositoryPHIDs) { if ($this->repositoryPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'repositoryPHID IN (%Ls)', 'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs); $this->repositoryPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
/** /**

View file

@ -116,54 +116,54 @@ final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $books; return $books;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if (strlen($this->nameLike)) { if (strlen($this->nameLike)) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'name LIKE %~', 'name LIKE %~',
$this->nameLike); $this->nameLike);
} }
if ($this->names !== null) { if ($this->names !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'name IN (%Ls)', 'name IN (%Ls)',
$this->names); $this->names);
} }
if (strlen($this->namePrefix)) { if (strlen($this->namePrefix)) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'name LIKE %>', 'name LIKE %>',
$this->namePrefix); $this->namePrefix);
} }
if ($this->repositoryPHIDs !== null) { if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'repositoryPHID IN (%Ls)', 'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs); $this->repositoryPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -86,26 +86,26 @@ final class PhabricatorFileChunkQuery
return $chunks; return $chunks;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->chunkHandles !== null) { if ($this->chunkHandles !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'chunkHandle IN (%Ls)', 'chunkHandle IN (%Ls)',
$this->chunkHandles); $this->chunkHandles);
} }
if ($this->rangeStart !== null) { if ($this->rangeStart !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'byteEnd > %d', 'byteEnd > %d',
$this->rangeStart); $this->rangeStart);
} }
if ($this->rangeEnd !== null) { if ($this->rangeEnd !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'byteStart < %d', 'byteStart < %d',
$this->rangeEnd); $this->rangeEnd);
} }
@ -113,18 +113,18 @@ final class PhabricatorFileChunkQuery
if ($this->isComplete !== null) { if ($this->isComplete !== null) {
if ($this->isComplete) { if ($this->isComplete) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'dataFilePHID IS NOT NULL'); 'dataFilePHID IS NOT NULL');
} else { } else {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'dataFilePHID IS NULL'); 'dataFilePHID IS NULL');
} }
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -123,40 +123,40 @@ final class PhabricatorFlagQuery
return $flags; return $flags;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ownerPHIDs) { if ($this->ownerPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'flag.ownerPHID IN (%Ls)', 'flag.ownerPHID IN (%Ls)',
$this->ownerPHIDs); $this->ownerPHIDs);
} }
if ($this->types) { if ($this->types) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'flag.type IN (%Ls)', 'flag.type IN (%Ls)',
$this->types); $this->types);
} }
if ($this->objectPHIDs) { if ($this->objectPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'flag.objectPHID IN (%Ls)', 'flag.objectPHID IN (%Ls)',
$this->objectPHIDs); $this->objectPHIDs);
} }
if ($this->colors) { if ($this->colors) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'flag.color IN (%Ld)', 'flag.color IN (%Ld)',
$this->colors); $this->colors);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -68,47 +68,47 @@ final class FundBackerQuery
return $backers; return $backers;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->initiativePHIDs !== null) { if ($this->initiativePHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'initiativePHID IN (%Ls)', 'initiativePHID IN (%Ls)',
$this->initiativePHIDs); $this->initiativePHIDs);
} }
if ($this->backerPHIDs !== null) { if ($this->backerPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'backerPHID IN (%Ls)', 'backerPHID IN (%Ls)',
$this->backerPHIDs); $this->backerPHIDs);
} }
if ($this->statuses !== null) { if ($this->statuses !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'status IN (%Ls)', 'status IN (%Ls)',
$this->statuses); $this->statuses);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -175,68 +175,68 @@ final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery {
return $rules; return $rules;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.id IN (%Ld)', 'rule.id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.phid IN (%Ls)', 'rule.phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->authorPHIDs) { if ($this->authorPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.authorPHID IN (%Ls)', 'rule.authorPHID IN (%Ls)',
$this->authorPHIDs); $this->authorPHIDs);
} }
if ($this->ruleTypes) { if ($this->ruleTypes) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.ruleType IN (%Ls)', 'rule.ruleType IN (%Ls)',
$this->ruleTypes); $this->ruleTypes);
} }
if ($this->contentTypes) { if ($this->contentTypes) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.contentType IN (%Ls)', 'rule.contentType IN (%Ls)',
$this->contentTypes); $this->contentTypes);
} }
if ($this->disabled !== null) { if ($this->disabled !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.isDisabled = %d', 'rule.isDisabled = %d',
(int)$this->disabled); (int)$this->disabled);
} }
if ($this->datasourceQuery) { if ($this->datasourceQuery) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.name LIKE %>', 'rule.name LIKE %>',
$this->datasourceQuery); $this->datasourceQuery);
} }
if ($this->triggerObjectPHIDs) { if ($this->triggerObjectPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'rule.triggerObjectPHID IN (%Ls)', 'rule.triggerObjectPHID IN (%Ls)',
$this->triggerObjectPHIDs); $this->triggerObjectPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function validateRuleAuthors(array $rules) { private function validateRuleAuthors(array $rules) {

View file

@ -91,33 +91,33 @@ final class HeraldTranscriptQuery
return $transcripts; return $transcripts;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->objectPHIDs) { if ($this->objectPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'objectPHID in (%Ls)', 'objectPHID in (%Ls)',
$this->objectPHIDs); $this->objectPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -86,61 +86,61 @@ final class LegalpadDocumentSignatureQuery
return $signatures; return $signatures;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->documentPHIDs !== null) { if ($this->documentPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'documentPHID IN (%Ls)', 'documentPHID IN (%Ls)',
$this->documentPHIDs); $this->documentPHIDs);
} }
if ($this->signerPHIDs !== null) { if ($this->signerPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'signerPHID IN (%Ls)', 'signerPHID IN (%Ls)',
$this->signerPHIDs); $this->signerPHIDs);
} }
if ($this->documentVersions !== null) { if ($this->documentVersions !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'documentVersion IN (%Ld)', 'documentVersion IN (%Ld)',
$this->documentVersions); $this->documentVersions);
} }
if ($this->secretKeys !== null) { if ($this->secretKeys !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'secretKey IN (%Ls)', 'secretKey IN (%Ls)',
$this->secretKeys); $this->secretKeys);
} }
if ($this->nameContains !== null) { if ($this->nameContains !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'signerName LIKE %~', 'signerName LIKE %~',
$this->nameContains); $this->nameContains);
} }
if ($this->emailContains !== null) { if ($this->emailContains !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'signerEmail LIKE %~', 'signerEmail LIKE %~',
$this->emailContains); $this->emailContains);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -37,33 +37,33 @@ final class PhabricatorOAuthServerClientQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->creatorPHIDs) { if ($this->creatorPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'creatorPHID IN (%Ls)', 'creatorPHID IN (%Ls)',
$this->creatorPHIDs); $this->creatorPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -37,33 +37,33 @@ final class PhluxVariableQuery
return $table->loadAllFromArray($rows); return $table->loadAllFromArray($rows);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->keys !== null) { if ($this->keys !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'variableKey IN (%Ls)', 'variableKey IN (%Ls)',
$this->keys); $this->keys);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function getDefaultOrderVector() { protected function getDefaultOrderVector() {

View file

@ -61,40 +61,40 @@ final class PholioImageQuery
return $images; return $images;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->mockIDs) { if ($this->mockIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'mockID IN (%Ld)', 'mockID IN (%Ld)',
$this->mockIDs); $this->mockIDs);
} }
if ($this->obsolete !== null) { if ($this->obsolete !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isObsolete = %d', 'isObsolete = %d',
$this->obsolete); $this->obsolete);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function willFilterPage(array $images) { protected function willFilterPage(array $images) {

View file

@ -99,7 +99,7 @@ final class PhortuneAccountQuery
$this->memberPHIDs); $this->memberPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function buildJoinClause(AphrontDatabaseConnection $conn) { protected function buildJoinClause(AphrontDatabaseConnection $conn) {

View file

@ -213,7 +213,7 @@ final class PhortuneCartQuery
} }
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -134,7 +134,7 @@ final class PhortuneChargeQuery
$this->statuses); $this->statuses);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -114,7 +114,7 @@ final class PhortuneMerchantQuery
$where[] = $this->buildPagingClause($conn); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function buildJoinClause(AphrontDatabaseConnection $conn) { protected function buildJoinClause(AphrontDatabaseConnection $conn) {

View file

@ -85,7 +85,7 @@ final class PhortunePaymentProviderConfigQuery
$where[] = $this->buildPagingClause($conn); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -105,12 +105,12 @@ final class PhortuneProductQuery
PhabricatorHash::digestForIndex($ref)); PhabricatorHash::digestForIndex($ref));
} }
} }
$where[] = implode(' OR ', $sql); $where[] = qsprintf($conn, '%LO', $sql);
} }
$where[] = $this->buildPagingClause($conn); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -100,7 +100,7 @@ final class PhortunePurchaseQuery
$this->cartPHIDs); $this->cartPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -182,7 +182,7 @@ final class PhortuneSubscriptionQuery
$this->statuses); $this->statuses);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -55,47 +55,47 @@ final class PhragmentFragmentQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->paths) { if ($this->paths) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'path IN (%Ls)', 'path IN (%Ls)',
$this->paths); $this->paths);
} }
if ($this->leadingPath) { if ($this->leadingPath) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'path LIKE %>', 'path LIKE %>',
$this->leadingPath); $this->leadingPath);
} }
if ($this->depths) { if ($this->depths) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'depth IN (%Ld)', 'depth IN (%Ld)',
$this->depths); $this->depths);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function didFilterPage(array $page) { protected function didFilterPage(array $page) {

View file

@ -49,47 +49,47 @@ final class PhragmentFragmentVersionQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->fragmentPHIDs) { if ($this->fragmentPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'fragmentPHID IN (%Ls)', 'fragmentPHID IN (%Ls)',
$this->fragmentPHIDs); $this->fragmentPHIDs);
} }
if ($this->sequences) { if ($this->sequences) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'sequence IN (%Ld)', 'sequence IN (%Ld)',
$this->sequences); $this->sequences);
} }
if ($this->sequenceBefore !== null) { if ($this->sequenceBefore !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'sequence < %d', 'sequence < %d',
$this->sequenceBefore); $this->sequenceBefore);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function willFilterPage(array $page) { protected function willFilterPage(array $page) {

View file

@ -55,40 +55,40 @@ final class PhragmentSnapshotChildQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->snapshotPHIDs) { if ($this->snapshotPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'snapshotPHID IN (%Ls)', 'snapshotPHID IN (%Ls)',
$this->snapshotPHIDs); $this->snapshotPHIDs);
} }
if ($this->fragmentPHIDs) { if ($this->fragmentPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'fragmentPHID IN (%Ls)', 'fragmentPHID IN (%Ls)',
$this->fragmentPHIDs); $this->fragmentPHIDs);
} }
if ($this->fragmentVersionPHIDs) { if ($this->fragmentVersionPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'fragmentVersionPHID IN (%Ls)', 'fragmentVersionPHID IN (%Ls)',
$this->fragmentVersionPHIDs); $this->fragmentVersionPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function willFilterPage(array $page) { protected function willFilterPage(array $page) {

View file

@ -43,40 +43,40 @@ final class PhragmentSnapshotQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->primaryFragmentPHIDs) { if ($this->primaryFragmentPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'primaryFragmentPHID IN (%Ls)', 'primaryFragmentPHID IN (%Ls)',
$this->primaryFragmentPHIDs); $this->primaryFragmentPHIDs);
} }
if ($this->names) { if ($this->names !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'name IN (%Ls)', 'name IN (%Ls)',
$this->names); $this->names);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function willFilterPage(array $page) { protected function willFilterPage(array $page) {

View file

@ -116,7 +116,7 @@ final class PhrequentUserTimeQuery
$where[] = $this->buildPagingClause($conn); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getOrderableColumns() { public function getOrderableColumns() {

View file

@ -103,26 +103,26 @@ final class ReleephBranchQuery
return $branches; return $branches;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->productIDs !== null) { if ($this->productIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'releephProjectID IN (%Ld)', 'releephProjectID IN (%Ld)',
$this->productIDs); $this->productIDs);
} }
@ -133,16 +133,16 @@ final class ReleephBranchQuery
break; break;
case self::STATUS_OPEN: case self::STATUS_OPEN:
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isActive = 1'); 'isActive = 1');
break; break;
default: default:
throw new Exception(pht("Unknown status constant '%s'!", $status)); throw new Exception(pht("Unknown status constant '%s'!", $status));
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -83,40 +83,40 @@ final class ReleephProductQuery
return $projects; return $projects;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->active !== null) { if ($this->active !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isActive = %d', 'isActive = %d',
(int)$this->active); (int)$this->active);
} }
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ls)', 'id IN (%Ls)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->repositoryPHIDs !== null) { if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'repositoryPHID IN (%Ls)', 'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs); $this->repositoryPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getOrderableColumns() { public function getOrderableColumns() {

View file

@ -147,54 +147,54 @@ final class ReleephRequestQuery
return $requests; return $requests;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->branchIDs !== null) { if ($this->branchIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'branchID IN (%Ld)', 'branchID IN (%Ld)',
$this->branchIDs); $this->branchIDs);
} }
if ($this->requestedCommitPHIDs !== null) { if ($this->requestedCommitPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'requestCommitPHID IN (%Ls)', 'requestCommitPHID IN (%Ls)',
$this->requestedCommitPHIDs); $this->requestedCommitPHIDs);
} }
if ($this->requestorPHIDs !== null) { if ($this->requestorPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'requestUserPHID IN (%Ls)', 'requestUserPHID IN (%Ls)',
$this->requestorPHIDs); $this->requestorPHIDs);
} }
if ($this->requestedObjectPHIDs !== null) { if ($this->requestedObjectPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'requestedObjectPHID IN (%Ls)', 'requestedObjectPHID IN (%Ls)',
$this->requestedObjectPHIDs); $this->requestedObjectPHIDs);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function getKeepStatusConstants() { private function getKeepStatusConstants() {

View file

@ -37,33 +37,33 @@ final class PhabricatorSavedQueryQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->engineClassNames !== null) { if ($this->engineClassNames !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'engineClassName IN (%Ls)', 'engineClassName IN (%Ls)',
$this->engineClassNames); $this->engineClassNames);
} }
if ($this->queryKeys !== null) { if ($this->queryKeys !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'queryKey IN (%Ls)', 'queryKey IN (%Ls)',
$this->queryKeys); $this->queryKeys);
} }
$where[] = $this->buildPagingClause($conn_r); $where[] = $this->buildPagingClause($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {

View file

@ -24,17 +24,17 @@ final class PhabricatorTokenCountQuery
return ipull($rows, 'tokenCount', 'objectPHID'); return ipull($rows, 'tokenCount', 'objectPHID');
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->objectPHIDs) { if ($this->objectPHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'objectPHID IN (%Ls)', 'objectPHID IN (%Ls)',
$this->objectPHIDs); $this->objectPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
} }

View file

@ -57,46 +57,48 @@ abstract class PhabricatorApplicationTransactionCommentQuery
return $table->loadAllFromArray($data); return $table->loadAllFromArray($data);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r)); return $this->formatWhereClause(
$conn,
$this->buildWhereClauseComponents($conn));
} }
protected function buildWhereClauseComponents( protected function buildWhereClauseComponents(
AphrontDatabaseConnection $conn_r) { AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.id IN (%Ld)', 'xcomment.id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.phid IN (%Ls)', 'xcomment.phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->authorPHIDs !== null) { if ($this->authorPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.authorPHID IN (%Ls)', 'xcomment.authorPHID IN (%Ls)',
$this->authorPHIDs); $this->authorPHIDs);
} }
if ($this->transactionPHIDs !== null) { if ($this->transactionPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.transactionPHID IN (%Ls)', 'xcomment.transactionPHID IN (%Ls)',
$this->transactionPHIDs); $this->transactionPHIDs);
} }
if ($this->isDeleted !== null) { if ($this->isDeleted !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.isDeleted = %d', 'xcomment.isDeleted = %d',
(int)$this->isDeleted); (int)$this->isDeleted);
} }
@ -104,11 +106,11 @@ abstract class PhabricatorApplicationTransactionCommentQuery
if ($this->hasTransaction !== null) { if ($this->hasTransaction !== null) {
if ($this->hasTransaction) { if ($this->hasTransaction) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.transactionPHID IS NOT NULL'); 'xcomment.transactionPHID IS NOT NULL');
} else { } else {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'xcomment.transactionPHID IS NULL'); 'xcomment.transactionPHID IS NULL');
} }
} }

View file

@ -209,39 +209,47 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery {
} }
protected function buildCustomWhereClause( protected function buildCustomWhereClause(
AphrontDatabaseConnection $conn_w, AphrontDatabaseConnection $conn,
$phase) { $phase) {
$where = array(); $where = array();
switch ($phase) { switch ($phase) {
case self::PHASE_LEASED: case self::PHASE_LEASED:
$where[] = 'leaseOwner IS NOT NULL'; $where[] = qsprintf(
$where[] = 'leaseExpires >= UNIX_TIMESTAMP()'; $conn,
'leaseOwner IS NOT NULL');
$where[] = qsprintf(
$conn,
'leaseExpires >= UNIX_TIMESTAMP()');
break; break;
case self::PHASE_UNLEASED: case self::PHASE_UNLEASED:
$where[] = 'leaseOwner IS NULL'; $where[] = qsprintf(
$conn,
'leaseOwner IS NULL');
break; break;
case self::PHASE_EXPIRED: case self::PHASE_EXPIRED:
$where[] = 'leaseExpires < UNIX_TIMESTAMP()'; $where[] = qsprintf(
$conn,
'leaseExpires < UNIX_TIMESTAMP()');
break; break;
default: default:
throw new Exception(pht("Unknown phase '%s'!", $phase)); throw new Exception(pht("Unknown phase '%s'!", $phase));
} }
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf($conn_w, 'id IN (%Ld)', $this->ids); $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids);
} }
if ($this->objectPHIDs !== null) { if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn_w, 'objectPHID IN (%Ls)', $this->objectPHIDs); $where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildUpdateWhereClause( private function buildUpdateWhereClause(
AphrontDatabaseConnection $conn_w, AphrontDatabaseConnection $conn,
$phase, $phase,
array $rows) { array $rows) {
@ -257,25 +265,25 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery {
'Trying to lease tasks selected in the leased phase! This is '. 'Trying to lease tasks selected in the leased phase! This is '.
'intended to be impossible.')); 'intended to be impossible.'));
case self::PHASE_UNLEASED: case self::PHASE_UNLEASED:
$where[] = qsprintf($conn_w, 'leaseOwner IS NULL'); $where[] = qsprintf($conn, 'leaseOwner IS NULL');
$where[] = qsprintf($conn_w, 'id IN (%Ld)', ipull($rows, 'id')); $where[] = qsprintf($conn, 'id IN (%Ld)', ipull($rows, 'id'));
break; break;
case self::PHASE_EXPIRED: case self::PHASE_EXPIRED:
$in = array(); $in = array();
foreach ($rows as $row) { foreach ($rows as $row) {
$in[] = qsprintf( $in[] = qsprintf(
$conn_w, $conn,
'(id = %d AND leaseOwner = %s)', '(id = %d AND leaseOwner = %s)',
$row['id'], $row['id'],
$row['leaseOwner']); $row['leaseOwner']);
} }
$where[] = qsprintf($conn_w, '(%Q)', implode(' OR ', $in)); $where[] = qsprintf($conn, '%LO', $in);
break; break;
default: default:
throw new Exception(pht('Unknown phase "%s"!', $phase)); throw new Exception(pht('Unknown phase "%s"!', $phase));
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildOrderClause(AphrontDatabaseConnection $conn_w, $phase) { private function buildOrderClause(AphrontDatabaseConnection $conn_w, $phase) {

View file

@ -48,59 +48,59 @@ abstract class PhabricatorWorkerTaskQuery
return $this; return $this;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id in (%Ld)', 'id in (%Ld)',
$this->ids); $this->ids);
} }
if ($this->objectPHIDs !== null) { if ($this->objectPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'objectPHID IN (%Ls)', 'objectPHID IN (%Ls)',
$this->objectPHIDs); $this->objectPHIDs);
} }
if ($this->dateModifiedSince !== null) { if ($this->dateModifiedSince !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'dateModified > %d', 'dateModified > %d',
$this->dateModifiedSince); $this->dateModifiedSince);
} }
if ($this->dateCreatedBefore !== null) { if ($this->dateCreatedBefore !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'dateCreated < %d', 'dateCreated < %d',
$this->dateCreatedBefore); $this->dateCreatedBefore);
} }
if ($this->classNames !== null) { if ($this->classNames !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'taskClass IN (%Ls)', 'taskClass IN (%Ls)',
$this->classNames); $this->classNames);
} }
if ($this->minFailureCount !== null) { if ($this->minFailureCount !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'failureCount >= %d', 'failureCount >= %d',
$this->minFailureCount); $this->minFailureCount);
} }
if ($this->maxFailureCount !== null) { if ($this->maxFailureCount !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'failureCount <= %d', 'failureCount <= %d',
$this->maxFailureCount); $this->maxFailureCount);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
protected function buildOrderClause(AphrontDatabaseConnection $conn_r) { protected function buildOrderClause(AphrontDatabaseConnection $conn_r) {

View file

@ -160,52 +160,52 @@ final class PhabricatorWorkerTriggerQuery
return implode(' ', $joins); return implode(' ', $joins);
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
't.id IN (%Ld)', 't.id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
't.phid IN (%Ls)', 't.phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->versionMin !== null) { if ($this->versionMin !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
't.triggerVersion >= %d', 't.triggerVersion >= %d',
$this->versionMin); $this->versionMin);
} }
if ($this->versionMax !== null) { if ($this->versionMax !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
't.triggerVersion <= %d', 't.triggerVersion <= %d',
$this->versionMax); $this->versionMax);
} }
if ($this->nextEpochMin !== null) { if ($this->nextEpochMin !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'e.nextEventEpoch >= %d', 'e.nextEventEpoch >= %d',
$this->nextEpochMin); $this->nextEpochMin);
} }
if ($this->nextEpochMax !== null) { if ($this->nextEpochMax !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'e.nextEventEpoch <= %d', 'e.nextEventEpoch <= %d',
$this->nextEpochMax); $this->nextEpochMax);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
private function buildOrderClause(AphrontDatabaseConnection $conn_r) { private function buildOrderClause(AphrontDatabaseConnection $conn_r) {

View file

@ -290,19 +290,19 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
/** /**
* @task internal * @task internal
*/ */
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = array(); $where = array();
if ($this->sourcePHIDs) { if ($this->sourcePHIDs) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'edge.src IN (%Ls)', 'edge.src IN (%Ls)',
$this->sourcePHIDs); $this->sourcePHIDs);
} }
if ($this->edgeTypes) { if ($this->edgeTypes) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'edge.type IN (%Ls)', 'edge.type IN (%Ls)',
$this->edgeTypes); $this->edgeTypes);
} }
@ -310,12 +310,12 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery {
if ($this->destPHIDs) { if ($this->destPHIDs) {
// potentially complain if $this->edgeType was not set // potentially complain if $this->edgeType was not set
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'edge.dst IN (%Ls)', 'edge.dst IN (%Ls)',
$this->destPHIDs); $this->destPHIDs);
} }
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }

View file

@ -27,15 +27,15 @@ abstract class PhabricatorOffsetPagedQuery extends PhabricatorQuery {
return $this->limit; return $this->limit;
} }
protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { protected function buildLimitClause(AphrontDatabaseConnection $conn) {
if ($this->limit && $this->offset) { if ($this->limit && $this->offset) {
return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, $this->limit); return qsprintf($conn, 'LIMIT %d, %d', $this->offset, $this->limit);
} else if ($this->limit) { } else if ($this->limit) {
return qsprintf($conn_r, 'LIMIT %d', $this->limit); return qsprintf($conn, 'LIMIT %d', $this->limit);
} else if ($this->offset) { } else if ($this->offset) {
return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX); return qsprintf($conn, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX);
} else { } else {
return ''; return qsprintf($conn, '');
} }
} }

View file

@ -15,28 +15,19 @@ abstract class PhabricatorQuery extends Phobject {
/** /**
* @task format * @task format
*/ */
protected function formatWhereClause(array $parts) { protected function formatWhereClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts); $parts = $this->flattenSubclause($parts);
if (!$parts) { if (!$parts) {
return ''; return qsprintf($conn, '');
} }
return 'WHERE '.$this->formatWhereSubclause($parts); return qsprintf($conn, 'WHERE %LA', $parts);
} }
/**
* @task format
*/
protected function formatWhereSubclause(array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return null;
}
return '('.implode(') AND (', $parts).')';
}
/** /**
* @task format * @task format
@ -57,39 +48,32 @@ abstract class PhabricatorQuery extends Phobject {
/** /**
* @task format * @task format
*/ */
protected function formatJoinClause(array $parts) { protected function formatJoinClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts); $parts = $this->flattenSubclause($parts);
if (!$parts) { if (!$parts) {
return ''; return qsprintf($conn, '');
} }
return implode(' ', $parts); return qsprintf($conn, '%LJ', $parts);
} }
/** /**
* @task format * @task format
*/ */
protected function formatHavingClause(array $parts) { protected function formatHavingClause(
AphrontDatabaseConnection $conn,
array $parts) {
$parts = $this->flattenSubclause($parts); $parts = $this->flattenSubclause($parts);
if (!$parts) { if (!$parts) {
return ''; return qsprintf($conn, '');
} }
return 'HAVING '.$this->formatHavingSubclause($parts); return qsprintf($conn, 'HAVING %LA', $parts);
}
/**
* @task format
*/
protected function formatHavingSubclause(array $parts) {
$parts = $this->flattenSubclause($parts);
if (!$parts) {
return null;
}
return '('.implode(') AND (', $parts).')';
} }

View file

@ -195,15 +195,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
} }
} }
final protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { final protected function buildLimitClause(AphrontDatabaseConnection $conn) {
if ($this->shouldLimitResults()) { if ($this->shouldLimitResults()) {
$limit = $this->getRawResultLimit(); $limit = $this->getRawResultLimit();
if ($limit) { if ($limit) {
return qsprintf($conn_r, 'LIMIT %d', $limit); return qsprintf($conn, 'LIMIT %d', $limit);
} }
} }
return ''; return qsprintf($conn, '');
} }
protected function shouldLimitResults() { protected function shouldLimitResults() {
@ -306,7 +306,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/ */
protected function buildJoinClause(AphrontDatabaseConnection $conn) { protected function buildJoinClause(AphrontDatabaseConnection $conn) {
$joins = $this->buildJoinClauseParts($conn); $joins = $this->buildJoinClauseParts($conn);
return $this->formatJoinClause($joins); return $this->formatJoinClause($conn, $joins);
} }
@ -328,7 +328,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/ */
protected function buildWhereClause(AphrontDatabaseConnection $conn) { protected function buildWhereClause(AphrontDatabaseConnection $conn) {
$where = $this->buildWhereClauseParts($conn); $where = $this->buildWhereClauseParts($conn);
return $this->formatWhereClause($where); return $this->formatWhereClause($conn, $where);
} }
@ -352,7 +352,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/ */
protected function buildHavingClause(AphrontDatabaseConnection $conn) { protected function buildHavingClause(AphrontDatabaseConnection $conn) {
$having = $this->buildHavingClauseParts($conn); $having = $this->buildHavingClauseParts($conn);
return $this->formatHavingClause($having); return $this->formatHavingClause($conn, $having);
} }
@ -371,13 +371,13 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/ */
protected function buildGroupClause(AphrontDatabaseConnection $conn) { protected function buildGroupClause(AphrontDatabaseConnection $conn) {
if (!$this->shouldGroupQueryResultRows()) { if (!$this->shouldGroupQueryResultRows()) {
return ''; return qsprintf($conn, '');
} }
return qsprintf( return qsprintf(
$conn, $conn,
'GROUP BY %Q', 'GROUP BY %Q',
$this->getApplicationSearchObjectPHIDColumn()); $this->getApplicationSearchObjectPHIDColumn($conn));
} }
@ -1134,7 +1134,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
} }
} }
return qsprintf($conn, 'ORDER BY %Q', implode(', ', $sql)); return qsprintf($conn, 'ORDER BY %LQ', $sql);
} }
@ -1244,17 +1244,18 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
* See @{method:getPrimaryTableAlias} if the column needs to be qualified with * See @{method:getPrimaryTableAlias} if the column needs to be qualified with
* a table alias. * a table alias.
* *
* @return string Column name. * @param AphrontDatabaseConnection Connection executing queries.
* @return PhutilQueryString Column name.
* @task appsearch * @task appsearch
*/ */
protected function getApplicationSearchObjectPHIDColumn() { protected function getApplicationSearchObjectPHIDColumn(
if ($this->getPrimaryTableAlias()) { AphrontDatabaseConnection $conn) {
$prefix = $this->getPrimaryTableAlias().'.';
} else {
$prefix = '';
}
return $prefix.'phid'; if ($this->getPrimaryTableAlias()) {
return qsprintf($conn, '%T.phid', $this->getPrimaryTableAlias());
} else {
return qsprintf($conn, 'phid');
}
} }
@ -1308,15 +1309,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
* @task appsearch * @task appsearch
*/ */
protected function buildApplicationSearchGroupClause( protected function buildApplicationSearchGroupClause(
AphrontDatabaseConnection $conn_r) { AphrontDatabaseConnection $conn) {
if ($this->getApplicationSearchMayJoinMultipleRows()) { if ($this->getApplicationSearchMayJoinMultipleRows()) {
return qsprintf( return qsprintf(
$conn_r, $conn,
'GROUP BY %Q', 'GROUP BY %Q',
$this->getApplicationSearchObjectPHIDColumn()); $this->getApplicationSearchObjectPHIDColumn());
} else { } else {
return ''; return qsprintf($conn, '');
} }
} }
@ -1410,7 +1411,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
} }
} }
$phid_column = $this->getApplicationSearchObjectPHIDColumn(); $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn);
$orderable = $this->getOrderableColumns(); $orderable = $this->getOrderableColumns();
$vector = $this->getOrderVector(); $vector = $this->getOrderVector();
@ -2373,7 +2374,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
*/ */
public function buildEdgeLogicJoinClause(AphrontDatabaseConnection $conn) { public function buildEdgeLogicJoinClause(AphrontDatabaseConnection $conn) {
$edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE;
$phid_column = $this->getApplicationSearchObjectPHIDColumn(); $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn);
$joins = array(); $joins = array();
foreach ($this->edgeLogicConstraints as $type => $constraints) { foreach ($this->edgeLogicConstraints as $type => $constraints) {
@ -2531,9 +2532,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
} }
if ($full && $null) { if ($full && $null) {
$full = $this->formatWhereSubclause($full); $where[] = qsprintf($conn, '(%LA OR %LA)', $full, $null);
$null = $this->formatWhereSubclause($null);
$where[] = qsprintf($conn, '(%Q OR %Q)', $full, $null);
} else if ($full) { } else if ($full) {
foreach ($full as $condition) { foreach ($full as $condition) {
$where[] = $condition; $where[] = $condition;

View file

@ -517,13 +517,14 @@ abstract class LiskDAO extends Phobject
protected function loadRawDataWhere($pattern /* , $args... */) { protected function loadRawDataWhere($pattern /* , $args... */) {
$connection = $this->establishConnection('r'); $conn = $this->establishConnection('r');
$lock_clause = ''; if ($conn->isReadLocking()) {
if ($connection->isReadLocking()) { $lock_clause = qsprintf($conn, 'FOR UPDATE');
$lock_clause = 'FOR UPDATE'; } else if ($conn->isWriteLocking()) {
} else if ($connection->isWriteLocking()) { $lock_clause = qsprintf($conn, 'LOCK IN SHARE MODE');
$lock_clause = 'LOCK IN SHARE MODE'; } else {
$lock_clause = qsprintf($conn, '');
} }
$args = func_get_args(); $args = func_get_args();
@ -534,9 +535,7 @@ abstract class LiskDAO extends Phobject
array_push($args, $lock_clause); array_push($args, $lock_clause);
array_unshift($args, $pattern); array_unshift($args, $pattern);
return call_user_func_array( return call_user_func_array(array($conn, 'queryData'), $args);
array($connection, 'queryData'),
$args);
} }