From 98690ee326ce314dfee8a7f27bd8007d61ecfbf0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 7 Nov 2018 02:48:26 -0800 Subject: [PATCH] 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 --- .../auth/query/PhabricatorAuthInviteQuery.php | 16 +++--- .../PhabricatorAuthProviderConfigQuery.php | 20 +++---- .../query/PhabricatorAuthSessionQuery.php | 22 +++---- .../PhabricatorCalendarEventInviteeQuery.php | 16 +++--- .../query/PhabricatorCalendarEventQuery.php | 4 -- .../query/PhabricatorChatLogChannelQuery.php | 10 ++-- .../chatlog/query/PhabricatorChatLogQuery.php | 14 ++--- .../query/PhabricatorConfigEntryQuery.php | 14 ++--- .../query/ConpherenceFulltextQuery.php | 10 ++-- .../ConpherenceParticipantCountQuery.php | 2 +- .../query/ConpherenceParticipantQuery.php | 2 +- .../query/PhabricatorDaemonLogQuery.php | 17 +++--- .../query/DifferentialInlineCommentQuery.php | 20 +++---- .../query/DifferentialRevisionQuery.php | 57 ++++++++++--------- .../query/DiffusionLintCountQuery.php | 8 +-- .../diffusion/query/DiffusionSymbolQuery.php | 16 +++--- .../diviner/query/DivinerAtomQuery.php | 38 ++++++------- .../diviner/query/DivinerBookQuery.php | 18 +++--- .../files/query/PhabricatorFileChunkQuery.php | 16 +++--- .../flag/query/PhabricatorFlagQuery.php | 14 ++--- .../fund/query/FundBackerQuery.php | 16 +++--- .../herald/query/HeraldRuleQuery.php | 22 +++---- .../herald/query/HeraldTranscriptQuery.php | 12 ++-- .../query/LegalpadDocumentSignatureQuery.php | 20 +++---- .../PhabricatorOAuthServerClientQuery.php | 12 ++-- .../phlux/query/PhluxVariableQuery.php | 12 ++-- .../pholio/query/PholioImageQuery.php | 14 ++--- .../phortune/query/PhortuneAccountQuery.php | 2 +- .../phortune/query/PhortuneCartQuery.php | 2 +- .../phortune/query/PhortuneChargeQuery.php | 2 +- .../phortune/query/PhortuneMerchantQuery.php | 2 +- .../PhortunePaymentProviderConfigQuery.php | 2 +- .../phortune/query/PhortuneProductQuery.php | 4 +- .../phortune/query/PhortunePurchaseQuery.php | 2 +- .../query/PhortuneSubscriptionQuery.php | 2 +- .../query/PhragmentFragmentQuery.php | 16 +++--- .../query/PhragmentFragmentVersionQuery.php | 16 +++--- .../query/PhragmentSnapshotChildQuery.php | 14 ++--- .../query/PhragmentSnapshotQuery.php | 22 +++---- .../query/PhrequentUserTimeQuery.php | 2 +- .../releeph/query/ReleephBranchQuery.php | 14 ++--- .../releeph/query/ReleephProductQuery.php | 14 ++--- .../releeph/query/ReleephRequestQuery.php | 18 +++--- .../query/PhabricatorSavedQueryQuery.php | 12 ++-- .../query/PhabricatorTokenCountQuery.php | 6 +- ...atorApplicationTransactionCommentQuery.php | 22 +++---- .../query/PhabricatorWorkerLeaseQuery.php | 36 +++++++----- .../query/PhabricatorWorkerTaskQuery.php | 18 +++--- .../query/PhabricatorWorkerTriggerQuery.php | 16 +++--- .../edges/query/PhabricatorEdgeQuery.php | 10 ++-- .../query/PhabricatorOffsetPagedQuery.php | 10 ++-- src/infrastructure/query/PhabricatorQuery.php | 52 ++++++----------- ...PhabricatorCursorPagedPolicyAwareQuery.php | 49 ++++++++-------- src/infrastructure/storage/lisk/LiskDAO.php | 17 +++--- 54 files changed, 407 insertions(+), 417 deletions(-) diff --git a/src/applications/auth/query/PhabricatorAuthInviteQuery.php b/src/applications/auth/query/PhabricatorAuthInviteQuery.php index 1ae617db65..55b325d603 100644 --- a/src/applications/auth/query/PhabricatorAuthInviteQuery.php +++ b/src/applications/auth/query/PhabricatorAuthInviteQuery.php @@ -59,26 +59,26 @@ final class PhabricatorAuthInviteQuery return $invites; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->emailAddresses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'emailAddress IN (%Ls)', $this->emailAddresses); } @@ -90,21 +90,21 @@ final class PhabricatorAuthInviteQuery } $where[] = qsprintf( - $conn_r, + $conn, 'verificationHash IN (%Ls)', $hashes); } if ($this->authorPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'authorPHID IN (%Ls)', $this->authorPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php b/src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php index 44e5913290..626c80348f 100644 --- a/src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php +++ b/src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php @@ -54,26 +54,26 @@ final class PhabricatorAuthProviderConfigQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - if ($this->ids) { + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - if ($this->providerClasses) { + if ($this->providerClasses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'providerClass IN (%Ls)', $this->providerClasses); } @@ -84,16 +84,16 @@ final class PhabricatorAuthProviderConfigQuery break; case self::STATUS_ENABLED: $where[] = qsprintf( - $conn_r, + $conn, 'isEnabled = 1'); break; default: 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() { diff --git a/src/applications/auth/query/PhabricatorAuthSessionQuery.php b/src/applications/auth/query/PhabricatorAuthSessionQuery.php index dea95dd450..25928e72c1 100644 --- a/src/applications/auth/query/PhabricatorAuthSessionQuery.php +++ b/src/applications/auth/query/PhabricatorAuthSessionQuery.php @@ -65,44 +65,44 @@ final class PhabricatorAuthSessionQuery return $sessions; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - if ($this->ids) { + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->identityPHIDs) { + if ($this->identityPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'userPHID IN (%Ls)', $this->identityPHIDs); } - if ($this->sessionKeys) { + if ($this->sessionKeys !== null) { $hashes = array(); foreach ($this->sessionKeys as $session_key) { $hashes[] = PhabricatorHash::weakDigest($session_key); } $where[] = qsprintf( - $conn_r, + $conn, 'sessionKey IN (%Ls)', $hashes); } - if ($this->sessionTypes) { + if ($this->sessionTypes !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'type IN (%Ls)', $this->sessionTypes); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php index 5ffa2a8aab..683d6cd918 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php @@ -49,47 +49,47 @@ final class PhabricatorCalendarEventInviteeQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->eventPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'eventPHID IN (%Ls)', $this->eventPHIDs); } if ($this->inviteePHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'inviteePHID IN (%Ls)', $this->inviteePHIDs); } if ($this->inviterPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'inviterPHID IN (%Ls)', $this->inviterPHIDs); } if ($this->statuses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'status = %d', $this->statuses); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php index 9b7189cfdf..2be76a631f 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventQuery.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventQuery.php @@ -509,10 +509,6 @@ final class PhabricatorCalendarEventQuery return parent::shouldGroupQueryResultRows(); } - protected function getApplicationSearchObjectPHIDColumn() { - return 'event.phid'; - } - public function getQueryApplicationClass() { return 'PhabricatorCalendarApplication'; } diff --git a/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php b/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php index 2aded5c11b..a13514eec7 100644 --- a/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php +++ b/src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php @@ -33,14 +33,14 @@ final class PhabricatorChatLogChannelQuery return $logs; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); if ($this->channelIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->channelIDs); @@ -48,12 +48,12 @@ final class PhabricatorChatLogChannelQuery if ($this->channels) { $where[] = qsprintf( - $conn_r, + $conn, 'channelName IN (%Ls)', $this->channels); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/chatlog/query/PhabricatorChatLogQuery.php b/src/applications/chatlog/query/PhabricatorChatLogQuery.php index d174fdac90..88cf6da7e3 100644 --- a/src/applications/chatlog/query/PhabricatorChatLogQuery.php +++ b/src/applications/chatlog/query/PhabricatorChatLogQuery.php @@ -55,26 +55,26 @@ final class PhabricatorChatLogQuery return $events; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - if ($this->maximumEpoch) { + if ($this->maximumEpoch !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'epoch <= %d', $this->maximumEpoch); } - if ($this->channelIDs) { + if ($this->channelIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'channelID IN (%Ld)', $this->channelIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/config/query/PhabricatorConfigEntryQuery.php b/src/applications/config/query/PhabricatorConfigEntryQuery.php index 56bf15a267..f46fdb7d1e 100644 --- a/src/applications/config/query/PhabricatorConfigEntryQuery.php +++ b/src/applications/config/query/PhabricatorConfigEntryQuery.php @@ -31,26 +31,26 @@ final class PhabricatorConfigEntryQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - if ($this->ids) { + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/conpherence/query/ConpherenceFulltextQuery.php b/src/applications/conpherence/query/ConpherenceFulltextQuery.php index ba734049f8..99ee4f559d 100644 --- a/src/applications/conpherence/query/ConpherenceFulltextQuery.php +++ b/src/applications/conpherence/query/ConpherenceFulltextQuery.php @@ -38,19 +38,19 @@ final class ConpherenceFulltextQuery return $rows; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->threadPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'i.threadPHID IN (%Ls)', $this->threadPHIDs); } if ($this->previousTransactionPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'i.previousTransactionPHID IN (%Ls)', $this->previousTransactionPHIDs); } @@ -61,12 +61,12 @@ final class ConpherenceFulltextQuery $compiled_query = $compiler->compileQuery($tokens); $where[] = qsprintf( - $conn_r, + $conn, 'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)', $compiled_query); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function buildOrderByClause(AphrontDatabaseConnection $conn_r) { diff --git a/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php b/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php index 268af0ccf1..c9ac9f76c1 100644 --- a/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php +++ b/src/applications/conpherence/query/ConpherenceParticipantCountQuery.php @@ -57,7 +57,7 @@ final class ConpherenceParticipantCountQuery } } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function buildGroupByClause(AphrontDatabaseConnection $conn) { diff --git a/src/applications/conpherence/query/ConpherenceParticipantQuery.php b/src/applications/conpherence/query/ConpherenceParticipantQuery.php index fb4c3eff0f..0316d5e2c2 100644 --- a/src/applications/conpherence/query/ConpherenceParticipantQuery.php +++ b/src/applications/conpherence/query/ConpherenceParticipantQuery.php @@ -38,7 +38,7 @@ final class ConpherenceParticipantQuery extends PhabricatorOffsetPagedQuery { $this->participantPHIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function buildOrderClause(AphrontDatabaseConnection $conn) { diff --git a/src/applications/daemon/query/PhabricatorDaemonLogQuery.php b/src/applications/daemon/query/PhabricatorDaemonLogQuery.php index 961c1cfc61..2c5b6baa3b 100644 --- a/src/applications/daemon/query/PhabricatorDaemonLogQuery.php +++ b/src/applications/daemon/query/PhabricatorDaemonLogQuery.php @@ -124,46 +124,47 @@ final class PhabricatorDaemonLogQuery return $daemons; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->notIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id NOT IN (%Ld)', $this->notIDs); } if ($this->getStatusConstants()) { $where[] = qsprintf( - $conn_r, + $conn, 'status IN (%Ls)', $this->getStatusConstants()); } if ($this->daemonClasses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'daemon IN (%Ls)', $this->daemonClasses); } if ($this->daemonIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'daemonID IN (%Ls)', $this->daemonIDs); } - $where[] = $this->buildPagingClause($conn_r); - return $this->formatWhereClause($where); + $where[] = $this->buildPagingClause($conn); + + return $this->formatWhereClause($conn, $where); } private function getStatusConstants() { diff --git a/src/applications/differential/query/DifferentialInlineCommentQuery.php b/src/applications/differential/query/DifferentialInlineCommentQuery.php index 3f8ea62e14..38549cd933 100644 --- a/src/applications/differential/query/DifferentialInlineCommentQuery.php +++ b/src/applications/differential/query/DifferentialInlineCommentQuery.php @@ -107,31 +107,31 @@ final class DifferentialInlineCommentQuery return head($this->execute()); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); // Only find inline comments. $where[] = qsprintf( - $conn_r, + $conn, 'changesetID IS NOT NULL'); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->revisionPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'revisionPHID IN (%Ls)', $this->revisionPHIDs); } @@ -139,28 +139,28 @@ final class DifferentialInlineCommentQuery if ($this->drafts === null) { if ($this->deletedDrafts) { $where[] = qsprintf( - $conn_r, + $conn, '(authorPHID = %s) OR (transactionPHID IS NOT NULL)', $this->getViewer()->getPHID()); } else { $where[] = qsprintf( - $conn_r, + $conn, '(authorPHID = %s AND isDeleted = 0) OR (transactionPHID IS NOT NULL)', $this->getViewer()->getPHID()); } } else if ($this->drafts) { $where[] = qsprintf( - $conn_r, + $conn, '(authorPHID = %s AND isDeleted = 0) AND (transactionPHID IS NULL)', $this->getViewer()->getPHID()); } else { $where[] = qsprintf( - $conn_r, + $conn, 'transactionPHID IS NOT NULL'); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function adjustInlinesForChangesets( diff --git a/src/applications/differential/query/DifferentialRevisionQuery.php b/src/applications/differential/query/DifferentialRevisionQuery.php index bc93de2db2..d24106328b 100644 --- a/src/applications/differential/query/DifferentialRevisionQuery.php +++ b/src/applications/differential/query/DifferentialRevisionQuery.php @@ -542,26 +542,26 @@ final class DifferentialRevisionQuery /** * @task internal */ - private function buildJoinsClause($conn_r) { + private function buildJoinsClause(AphrontDatabaseConnection $conn) { $joins = array(); if ($this->pathIDs) { $path_table = new DifferentialAffectedPath(); $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T p ON p.revisionID = r.id', $path_table->getTableName()); } if ($this->commitHashes) { $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T hash_rel ON hash_rel.revisionID = r.id', ArcanistDifferentialRevisionHash::TABLE_NAME); } if ($this->ccs) { $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T e_ccs ON e_ccs.src = r.phid '. 'AND e_ccs.type = %s '. 'AND e_ccs.dst in (%Ls)', @@ -572,7 +572,7 @@ final class DifferentialRevisionQuery if ($this->reviewers) { $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T reviewer ON reviewer.revisionPHID = r.phid AND reviewer.reviewerStatus != %s AND reviewer.reviewerPHID in (%Ls)', @@ -583,7 +583,7 @@ final class DifferentialRevisionQuery if ($this->draftAuthors) { $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T has_draft ON has_draft.srcPHID = r.phid AND has_draft.type = %s AND has_draft.dstPHID IN (%Ls)', @@ -594,21 +594,21 @@ final class DifferentialRevisionQuery if ($this->commitPHIDs) { $joins[] = qsprintf( - $conn_r, + $conn, 'JOIN %T commits ON commits.revisionID = r.id', DifferentialRevision::TABLE_COMMIT); } - $joins[] = $this->buildJoinClauseParts($conn_r); + $joins[] = $this->buildJoinClauseParts($conn); - return $this->formatJoinClause($joins); + return $this->formatJoinClause($conn, $joins); } /** * @task internal */ - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->pathIDs) { @@ -616,32 +616,32 @@ final class DifferentialRevisionQuery $repo_info = igroup($this->pathIDs, 'repositoryID'); foreach ($repo_info as $repository_id => $paths) { $path_clauses[] = qsprintf( - $conn_r, + $conn, '(p.repositoryID = %d AND p.pathID IN (%Ld))', $repository_id, ipull($paths, 'pathID')); } - $path_clauses = '('.implode(' OR ', $path_clauses).')'; + $path_clauses = qsprintf($conn, '%LO', $path_clauses); $where[] = $path_clauses; } if ($this->authors) { $where[] = qsprintf( - $conn_r, + $conn, 'r.authorPHID IN (%Ls)', $this->authors); } if ($this->revIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'r.id IN (%Ld)', $this->revIDs); } if ($this->repositoryPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'r.repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } @@ -651,67 +651,67 @@ final class DifferentialRevisionQuery foreach ($this->commitHashes as $info) { list($type, $hash) = $info; $hash_clauses[] = qsprintf( - $conn_r, + $conn, '(hash_rel.type = %s AND hash_rel.hash = %s)', $type, $hash); } - $hash_clauses = '('.implode(' OR ', $hash_clauses).')'; + $hash_clauses = qsprintf($conn, '%LO', $hash_clauses); $where[] = $hash_clauses; } if ($this->commitPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'commits.commitPHID IN (%Ls)', $this->commitPHIDs); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'r.phid IN (%Ls)', $this->phids); } if ($this->branches) { $where[] = qsprintf( - $conn_r, + $conn, 'r.branchName in (%Ls)', $this->branches); } if ($this->updatedEpochMin !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'r.dateModified >= %d', $this->updatedEpochMin); } if ($this->updatedEpochMax !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'r.dateModified <= %d', $this->updatedEpochMax); } if ($this->createdEpochMin !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'r.dateCreated >= %d', $this->createdEpochMin); } if ($this->createdEpochMax !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'r.dateCreated <= %d', $this->createdEpochMax); } if ($this->statuses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'r.status in (%Ls)', $this->statuses); } @@ -725,13 +725,14 @@ final class DifferentialRevisionQuery DifferentialLegacyQuery::STATUS_CLOSED); } $where[] = qsprintf( - $conn_r, + $conn, 'r.status in (%Ls)', $statuses); } - $where[] = $this->buildWhereClauseParts($conn_r); - return $this->formatWhereClause($where); + $where[] = $this->buildWhereClauseParts($conn); + + return $this->formatWhereClause($conn, $where); } diff --git a/src/applications/diffusion/query/DiffusionLintCountQuery.php b/src/applications/diffusion/query/DiffusionLintCountQuery.php index 4441ccf3ef..2c1a2a9867 100644 --- a/src/applications/diffusion/query/DiffusionLintCountQuery.php +++ b/src/applications/diffusion/query/DiffusionLintCountQuery.php @@ -70,7 +70,7 @@ final class DiffusionLintCountQuery extends PhabricatorQuery { } protected function buildCustomWhereClause( - AphrontDatabaseConnection $conn_r, + AphrontDatabaseConnection $conn, $part) { $where = array(); @@ -79,19 +79,19 @@ final class DiffusionLintCountQuery extends PhabricatorQuery { if ($this->codes !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'code IN (%Ls)', $this->codes); } if ($this->branchIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'branchID IN (%Ld)', $this->branchIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function processPaths() { diff --git a/src/applications/diffusion/query/DiffusionSymbolQuery.php b/src/applications/diffusion/query/DiffusionSymbolQuery.php index 0e08b7b32d..3415fbbefa 100644 --- a/src/applications/diffusion/query/DiffusionSymbolQuery.php +++ b/src/applications/diffusion/query/DiffusionSymbolQuery.php @@ -192,52 +192,52 @@ final class DiffusionSymbolQuery extends PhabricatorOffsetPagedQuery { /** * @task internal */ - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if (isset($this->context)) { $where[] = qsprintf( - $conn_r, + $conn, 'symbolContext = %s', $this->context); } if ($this->name) { $where[] = qsprintf( - $conn_r, + $conn, 'symbolName = %s', $this->name); } if ($this->namePrefix) { $where[] = qsprintf( - $conn_r, + $conn, 'symbolName LIKE %>', $this->namePrefix); } if ($this->repositoryPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } if ($this->language) { $where[] = qsprintf( - $conn_r, + $conn, 'symbolLanguage = %s', $this->language); } if ($this->type) { $where[] = qsprintf( - $conn_r, + $conn, 'symbolType = %s', $this->type); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } diff --git a/src/applications/diviner/query/DivinerAtomQuery.php b/src/applications/diviner/query/DivinerAtomQuery.php index 5f4900d4dd..65a5634008 100644 --- a/src/applications/diviner/query/DivinerAtomQuery.php +++ b/src/applications/diviner/query/DivinerAtomQuery.php @@ -299,40 +299,40 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery { return $atoms; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->bookPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'bookPHID IN (%Ls)', $this->bookPHIDs); } if ($this->types) { $where[] = qsprintf( - $conn_r, + $conn, 'type IN (%Ls)', $this->types); } if ($this->names) { $where[] = qsprintf( - $conn_r, + $conn, 'name IN (%Ls)', $this->names); } @@ -347,7 +347,7 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery { } $where[] = qsprintf( - $conn_r, + $conn, 'titleSlugHash in (%Ls)', $hashes); } @@ -366,46 +366,46 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery { if ($contexts && $with_null) { $where[] = qsprintf( - $conn_r, + $conn, 'context IN (%Ls) OR context IS NULL', $contexts); } else if ($contexts) { $where[] = qsprintf( - $conn_r, + $conn, 'context IN (%Ls)', $contexts); } else if ($with_null) { $where[] = qsprintf( - $conn_r, + $conn, 'context IS NULL'); } } if ($this->indexes) { $where[] = qsprintf( - $conn_r, + $conn, 'atomIndex IN (%Ld)', $this->indexes); } if ($this->isDocumentable !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'isDocumentable = %d', (int)$this->isDocumentable); } if ($this->isGhost !== null) { if ($this->isGhost) { - $where[] = qsprintf($conn_r, 'graphHash IS NULL'); + $where[] = qsprintf($conn, 'graphHash IS NULL'); } else { - $where[] = qsprintf($conn_r, 'graphHash IS NOT NULL'); + $where[] = qsprintf($conn, 'graphHash IS NOT NULL'); } } if ($this->nodeHashes) { $where[] = qsprintf( - $conn_r, + $conn, 'nodeHash IN (%Ls)', $this->nodeHashes); } @@ -415,21 +415,21 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery { // the column has binary collation. Eventually, this should move into // fulltext. $where[] = qsprintf( - $conn_r, + $conn, 'CONVERT(name USING utf8) LIKE %~', $this->nameContains); } if ($this->repositoryPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } /** diff --git a/src/applications/diviner/query/DivinerBookQuery.php b/src/applications/diviner/query/DivinerBookQuery.php index 8e6726ef5c..d540d971b0 100644 --- a/src/applications/diviner/query/DivinerBookQuery.php +++ b/src/applications/diviner/query/DivinerBookQuery.php @@ -116,54 +116,54 @@ final class DivinerBookQuery extends PhabricatorCursorPagedPolicyAwareQuery { return $books; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if (strlen($this->nameLike)) { $where[] = qsprintf( - $conn_r, + $conn, 'name LIKE %~', $this->nameLike); } if ($this->names !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'name IN (%Ls)', $this->names); } if (strlen($this->namePrefix)) { $where[] = qsprintf( - $conn_r, + $conn, 'name LIKE %>', $this->namePrefix); } if ($this->repositoryPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/files/query/PhabricatorFileChunkQuery.php b/src/applications/files/query/PhabricatorFileChunkQuery.php index b6fda13103..4398860569 100644 --- a/src/applications/files/query/PhabricatorFileChunkQuery.php +++ b/src/applications/files/query/PhabricatorFileChunkQuery.php @@ -86,26 +86,26 @@ final class PhabricatorFileChunkQuery return $chunks; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->chunkHandles !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'chunkHandle IN (%Ls)', $this->chunkHandles); } if ($this->rangeStart !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'byteEnd > %d', $this->rangeStart); } if ($this->rangeEnd !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'byteStart < %d', $this->rangeEnd); } @@ -113,18 +113,18 @@ final class PhabricatorFileChunkQuery if ($this->isComplete !== null) { if ($this->isComplete) { $where[] = qsprintf( - $conn_r, + $conn, 'dataFilePHID IS NOT NULL'); } else { $where[] = qsprintf( - $conn_r, + $conn, 'dataFilePHID IS NULL'); } } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/flag/query/PhabricatorFlagQuery.php b/src/applications/flag/query/PhabricatorFlagQuery.php index ff154a512b..3418f10746 100644 --- a/src/applications/flag/query/PhabricatorFlagQuery.php +++ b/src/applications/flag/query/PhabricatorFlagQuery.php @@ -123,40 +123,40 @@ final class PhabricatorFlagQuery return $flags; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ownerPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'flag.ownerPHID IN (%Ls)', $this->ownerPHIDs); } if ($this->types) { $where[] = qsprintf( - $conn_r, + $conn, 'flag.type IN (%Ls)', $this->types); } if ($this->objectPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'flag.objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->colors) { $where[] = qsprintf( - $conn_r, + $conn, 'flag.color IN (%Ld)', $this->colors); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/fund/query/FundBackerQuery.php b/src/applications/fund/query/FundBackerQuery.php index 5f7406f5ad..2d6e13dfd9 100644 --- a/src/applications/fund/query/FundBackerQuery.php +++ b/src/applications/fund/query/FundBackerQuery.php @@ -68,47 +68,47 @@ final class FundBackerQuery return $backers; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->initiativePHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'initiativePHID IN (%Ls)', $this->initiativePHIDs); } if ($this->backerPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'backerPHID IN (%Ls)', $this->backerPHIDs); } if ($this->statuses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'status IN (%Ls)', $this->statuses); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/herald/query/HeraldRuleQuery.php b/src/applications/herald/query/HeraldRuleQuery.php index 88df18db24..9673bd0810 100644 --- a/src/applications/herald/query/HeraldRuleQuery.php +++ b/src/applications/herald/query/HeraldRuleQuery.php @@ -175,68 +175,68 @@ final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery { return $rules; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->ruleTypes) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.ruleType IN (%Ls)', $this->ruleTypes); } if ($this->contentTypes) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.contentType IN (%Ls)', $this->contentTypes); } if ($this->disabled !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.isDisabled = %d', (int)$this->disabled); } if ($this->datasourceQuery) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.name LIKE %>', $this->datasourceQuery); } if ($this->triggerObjectPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'rule.triggerObjectPHID IN (%Ls)', $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) { diff --git a/src/applications/herald/query/HeraldTranscriptQuery.php b/src/applications/herald/query/HeraldTranscriptQuery.php index 7d0fdfc59e..5308e05ee1 100644 --- a/src/applications/herald/query/HeraldTranscriptQuery.php +++ b/src/applications/herald/query/HeraldTranscriptQuery.php @@ -91,33 +91,33 @@ final class HeraldTranscriptQuery return $transcripts; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->objectPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'objectPHID in (%Ls)', $this->objectPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php b/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php index 452ea6759b..c310dd3d64 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php +++ b/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php @@ -86,61 +86,61 @@ final class LegalpadDocumentSignatureQuery return $signatures; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->documentPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'documentPHID IN (%Ls)', $this->documentPHIDs); } if ($this->signerPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'signerPHID IN (%Ls)', $this->signerPHIDs); } if ($this->documentVersions !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'documentVersion IN (%Ld)', $this->documentVersions); } if ($this->secretKeys !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'secretKey IN (%Ls)', $this->secretKeys); } if ($this->nameContains !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'signerName LIKE %~', $this->nameContains); } if ($this->emailContains !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'signerEmail LIKE %~', $this->emailContains); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/oauthserver/query/PhabricatorOAuthServerClientQuery.php b/src/applications/oauthserver/query/PhabricatorOAuthServerClientQuery.php index b5da9ecd5f..46fc514824 100644 --- a/src/applications/oauthserver/query/PhabricatorOAuthServerClientQuery.php +++ b/src/applications/oauthserver/query/PhabricatorOAuthServerClientQuery.php @@ -37,33 +37,33 @@ final class PhabricatorOAuthServerClientQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->creatorPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'creatorPHID IN (%Ls)', $this->creatorPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phlux/query/PhluxVariableQuery.php b/src/applications/phlux/query/PhluxVariableQuery.php index 82072485d4..75abd044d0 100644 --- a/src/applications/phlux/query/PhluxVariableQuery.php +++ b/src/applications/phlux/query/PhluxVariableQuery.php @@ -37,33 +37,33 @@ final class PhluxVariableQuery return $table->loadAllFromArray($rows); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->keys !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'variableKey IN (%Ls)', $this->keys); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } protected function getDefaultOrderVector() { diff --git a/src/applications/pholio/query/PholioImageQuery.php b/src/applications/pholio/query/PholioImageQuery.php index 8c722660cb..79ffdc56d7 100644 --- a/src/applications/pholio/query/PholioImageQuery.php +++ b/src/applications/pholio/query/PholioImageQuery.php @@ -61,40 +61,40 @@ final class PholioImageQuery return $images; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->mockIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'mockID IN (%Ld)', $this->mockIDs); } if ($this->obsolete !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'isObsolete = %d', $this->obsolete); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } protected function willFilterPage(array $images) { diff --git a/src/applications/phortune/query/PhortuneAccountQuery.php b/src/applications/phortune/query/PhortuneAccountQuery.php index c91e5f0111..4ada4f2845 100644 --- a/src/applications/phortune/query/PhortuneAccountQuery.php +++ b/src/applications/phortune/query/PhortuneAccountQuery.php @@ -99,7 +99,7 @@ final class PhortuneAccountQuery $this->memberPHIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } protected function buildJoinClause(AphrontDatabaseConnection $conn) { diff --git a/src/applications/phortune/query/PhortuneCartQuery.php b/src/applications/phortune/query/PhortuneCartQuery.php index 5009d3a685..0b3325b932 100644 --- a/src/applications/phortune/query/PhortuneCartQuery.php +++ b/src/applications/phortune/query/PhortuneCartQuery.php @@ -213,7 +213,7 @@ final class PhortuneCartQuery } } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phortune/query/PhortuneChargeQuery.php b/src/applications/phortune/query/PhortuneChargeQuery.php index 6b11cbe95e..a7eda9d6a6 100644 --- a/src/applications/phortune/query/PhortuneChargeQuery.php +++ b/src/applications/phortune/query/PhortuneChargeQuery.php @@ -134,7 +134,7 @@ final class PhortuneChargeQuery $this->statuses); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phortune/query/PhortuneMerchantQuery.php b/src/applications/phortune/query/PhortuneMerchantQuery.php index c91267b73c..033621a3f1 100644 --- a/src/applications/phortune/query/PhortuneMerchantQuery.php +++ b/src/applications/phortune/query/PhortuneMerchantQuery.php @@ -114,7 +114,7 @@ final class PhortuneMerchantQuery $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } protected function buildJoinClause(AphrontDatabaseConnection $conn) { diff --git a/src/applications/phortune/query/PhortunePaymentProviderConfigQuery.php b/src/applications/phortune/query/PhortunePaymentProviderConfigQuery.php index d80b0e90d0..a850acec28 100644 --- a/src/applications/phortune/query/PhortunePaymentProviderConfigQuery.php +++ b/src/applications/phortune/query/PhortunePaymentProviderConfigQuery.php @@ -85,7 +85,7 @@ final class PhortunePaymentProviderConfigQuery $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phortune/query/PhortuneProductQuery.php b/src/applications/phortune/query/PhortuneProductQuery.php index 99ba535585..30701d4e7b 100644 --- a/src/applications/phortune/query/PhortuneProductQuery.php +++ b/src/applications/phortune/query/PhortuneProductQuery.php @@ -105,12 +105,12 @@ final class PhortuneProductQuery PhabricatorHash::digestForIndex($ref)); } } - $where[] = implode(' OR ', $sql); + $where[] = qsprintf($conn, '%LO', $sql); } $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phortune/query/PhortunePurchaseQuery.php b/src/applications/phortune/query/PhortunePurchaseQuery.php index 6e9e599240..275537c351 100644 --- a/src/applications/phortune/query/PhortunePurchaseQuery.php +++ b/src/applications/phortune/query/PhortunePurchaseQuery.php @@ -100,7 +100,7 @@ final class PhortunePurchaseQuery $this->cartPHIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phortune/query/PhortuneSubscriptionQuery.php b/src/applications/phortune/query/PhortuneSubscriptionQuery.php index e8b39c0fee..6919e6a169 100644 --- a/src/applications/phortune/query/PhortuneSubscriptionQuery.php +++ b/src/applications/phortune/query/PhortuneSubscriptionQuery.php @@ -182,7 +182,7 @@ final class PhortuneSubscriptionQuery $this->statuses); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/phragment/query/PhragmentFragmentQuery.php b/src/applications/phragment/query/PhragmentFragmentQuery.php index d6dc67609d..56444217db 100644 --- a/src/applications/phragment/query/PhragmentFragmentQuery.php +++ b/src/applications/phragment/query/PhragmentFragmentQuery.php @@ -55,47 +55,47 @@ final class PhragmentFragmentQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->paths) { $where[] = qsprintf( - $conn_r, + $conn, 'path IN (%Ls)', $this->paths); } if ($this->leadingPath) { $where[] = qsprintf( - $conn_r, + $conn, 'path LIKE %>', $this->leadingPath); } if ($this->depths) { $where[] = qsprintf( - $conn_r, + $conn, 'depth IN (%Ld)', $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) { diff --git a/src/applications/phragment/query/PhragmentFragmentVersionQuery.php b/src/applications/phragment/query/PhragmentFragmentVersionQuery.php index a874a8be1a..e95c3260a8 100644 --- a/src/applications/phragment/query/PhragmentFragmentVersionQuery.php +++ b/src/applications/phragment/query/PhragmentFragmentVersionQuery.php @@ -49,47 +49,47 @@ final class PhragmentFragmentVersionQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->fragmentPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'fragmentPHID IN (%Ls)', $this->fragmentPHIDs); } if ($this->sequences) { $where[] = qsprintf( - $conn_r, + $conn, 'sequence IN (%Ld)', $this->sequences); } if ($this->sequenceBefore !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'sequence < %d', $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) { diff --git a/src/applications/phragment/query/PhragmentSnapshotChildQuery.php b/src/applications/phragment/query/PhragmentSnapshotChildQuery.php index 032fb0c49c..faa3493499 100644 --- a/src/applications/phragment/query/PhragmentSnapshotChildQuery.php +++ b/src/applications/phragment/query/PhragmentSnapshotChildQuery.php @@ -55,40 +55,40 @@ final class PhragmentSnapshotChildQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->snapshotPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'snapshotPHID IN (%Ls)', $this->snapshotPHIDs); } if ($this->fragmentPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'fragmentPHID IN (%Ls)', $this->fragmentPHIDs); } if ($this->fragmentVersionPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'fragmentVersionPHID IN (%Ls)', $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) { diff --git a/src/applications/phragment/query/PhragmentSnapshotQuery.php b/src/applications/phragment/query/PhragmentSnapshotQuery.php index d6f9d3422f..a4805650fc 100644 --- a/src/applications/phragment/query/PhragmentSnapshotQuery.php +++ b/src/applications/phragment/query/PhragmentSnapshotQuery.php @@ -43,40 +43,40 @@ final class PhragmentSnapshotQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); - if ($this->ids) { + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - if ($this->primaryFragmentPHIDs) { + if ($this->primaryFragmentPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'primaryFragmentPHID IN (%Ls)', $this->primaryFragmentPHIDs); } - if ($this->names) { + if ($this->names !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'name IN (%Ls)', $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) { diff --git a/src/applications/phrequent/query/PhrequentUserTimeQuery.php b/src/applications/phrequent/query/PhrequentUserTimeQuery.php index d0d1160df0..7fb77f0f76 100644 --- a/src/applications/phrequent/query/PhrequentUserTimeQuery.php +++ b/src/applications/phrequent/query/PhrequentUserTimeQuery.php @@ -116,7 +116,7 @@ final class PhrequentUserTimeQuery $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getOrderableColumns() { diff --git a/src/applications/releeph/query/ReleephBranchQuery.php b/src/applications/releeph/query/ReleephBranchQuery.php index 9d7c884012..97e47bdcaf 100644 --- a/src/applications/releeph/query/ReleephBranchQuery.php +++ b/src/applications/releeph/query/ReleephBranchQuery.php @@ -103,26 +103,26 @@ final class ReleephBranchQuery return $branches; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->productIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'releephProjectID IN (%Ld)', $this->productIDs); } @@ -133,16 +133,16 @@ final class ReleephBranchQuery break; case self::STATUS_OPEN: $where[] = qsprintf( - $conn_r, + $conn, 'isActive = 1'); break; default: 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() { diff --git a/src/applications/releeph/query/ReleephProductQuery.php b/src/applications/releeph/query/ReleephProductQuery.php index acfc39c1c2..c039950379 100644 --- a/src/applications/releeph/query/ReleephProductQuery.php +++ b/src/applications/releeph/query/ReleephProductQuery.php @@ -83,40 +83,40 @@ final class ReleephProductQuery return $projects; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->active !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'isActive = %d', (int)$this->active); } if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ls)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->repositoryPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'repositoryPHID IN (%Ls)', $this->repositoryPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getOrderableColumns() { diff --git a/src/applications/releeph/query/ReleephRequestQuery.php b/src/applications/releeph/query/ReleephRequestQuery.php index 7d4f19e624..3042260387 100644 --- a/src/applications/releeph/query/ReleephRequestQuery.php +++ b/src/applications/releeph/query/ReleephRequestQuery.php @@ -147,54 +147,54 @@ final class ReleephRequestQuery return $requests; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } if ($this->branchIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'branchID IN (%Ld)', $this->branchIDs); } if ($this->requestedCommitPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'requestCommitPHID IN (%Ls)', $this->requestedCommitPHIDs); } if ($this->requestorPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'requestUserPHID IN (%Ls)', $this->requestorPHIDs); } if ($this->requestedObjectPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'requestedObjectPHID IN (%Ls)', $this->requestedObjectPHIDs); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function getKeepStatusConstants() { diff --git a/src/applications/search/query/PhabricatorSavedQueryQuery.php b/src/applications/search/query/PhabricatorSavedQueryQuery.php index 623b001662..765c751940 100644 --- a/src/applications/search/query/PhabricatorSavedQueryQuery.php +++ b/src/applications/search/query/PhabricatorSavedQueryQuery.php @@ -37,33 +37,33 @@ final class PhabricatorSavedQueryQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } if ($this->engineClassNames !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'engineClassName IN (%Ls)', $this->engineClassNames); } if ($this->queryKeys !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'queryKey IN (%Ls)', $this->queryKeys); } - $where[] = $this->buildPagingClause($conn_r); + $where[] = $this->buildPagingClause($conn); - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } public function getQueryApplicationClass() { diff --git a/src/applications/tokens/query/PhabricatorTokenCountQuery.php b/src/applications/tokens/query/PhabricatorTokenCountQuery.php index 64333715fd..c4694af607 100644 --- a/src/applications/tokens/query/PhabricatorTokenCountQuery.php +++ b/src/applications/tokens/query/PhabricatorTokenCountQuery.php @@ -24,17 +24,17 @@ final class PhabricatorTokenCountQuery return ipull($rows, 'tokenCount', 'objectPHID'); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->objectPHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } } diff --git a/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php b/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php index f79de81ba3..4ca56101fc 100644 --- a/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php +++ b/src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php @@ -57,46 +57,48 @@ abstract class PhabricatorApplicationTransactionCommentQuery return $table->loadAllFromArray($data); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r)); + protected function buildWhereClause(AphrontDatabaseConnection $conn) { + return $this->formatWhereClause( + $conn, + $this->buildWhereClauseComponents($conn)); } protected function buildWhereClauseComponents( - AphrontDatabaseConnection $conn_r) { + AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.phid IN (%Ls)', $this->phids); } if ($this->authorPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.authorPHID IN (%Ls)', $this->authorPHIDs); } if ($this->transactionPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.transactionPHID IN (%Ls)', $this->transactionPHIDs); } if ($this->isDeleted !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.isDeleted = %d', (int)$this->isDeleted); } @@ -104,11 +106,11 @@ abstract class PhabricatorApplicationTransactionCommentQuery if ($this->hasTransaction !== null) { if ($this->hasTransaction) { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.transactionPHID IS NOT NULL'); } else { $where[] = qsprintf( - $conn_r, + $conn, 'xcomment.transactionPHID IS NULL'); } } diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php index bb70f03d88..0163143ae7 100644 --- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php +++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php @@ -209,39 +209,47 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery { } protected function buildCustomWhereClause( - AphrontDatabaseConnection $conn_w, + AphrontDatabaseConnection $conn, $phase) { $where = array(); switch ($phase) { case self::PHASE_LEASED: - $where[] = 'leaseOwner IS NOT NULL'; - $where[] = 'leaseExpires >= UNIX_TIMESTAMP()'; + $where[] = qsprintf( + $conn, + 'leaseOwner IS NOT NULL'); + $where[] = qsprintf( + $conn, + 'leaseExpires >= UNIX_TIMESTAMP()'); break; case self::PHASE_UNLEASED: - $where[] = 'leaseOwner IS NULL'; + $where[] = qsprintf( + $conn, + 'leaseOwner IS NULL'); break; case self::PHASE_EXPIRED: - $where[] = 'leaseExpires < UNIX_TIMESTAMP()'; + $where[] = qsprintf( + $conn, + 'leaseExpires < UNIX_TIMESTAMP()'); break; default: throw new Exception(pht("Unknown phase '%s'!", $phase)); } 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) { - $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( - AphrontDatabaseConnection $conn_w, + AphrontDatabaseConnection $conn, $phase, array $rows) { @@ -257,25 +265,25 @@ final class PhabricatorWorkerLeaseQuery extends PhabricatorQuery { 'Trying to lease tasks selected in the leased phase! This is '. 'intended to be impossible.')); case self::PHASE_UNLEASED: - $where[] = qsprintf($conn_w, 'leaseOwner IS NULL'); - $where[] = qsprintf($conn_w, 'id IN (%Ld)', ipull($rows, 'id')); + $where[] = qsprintf($conn, 'leaseOwner IS NULL'); + $where[] = qsprintf($conn, 'id IN (%Ld)', ipull($rows, 'id')); break; case self::PHASE_EXPIRED: $in = array(); foreach ($rows as $row) { $in[] = qsprintf( - $conn_w, + $conn, '(id = %d AND leaseOwner = %s)', $row['id'], $row['leaseOwner']); } - $where[] = qsprintf($conn_w, '(%Q)', implode(' OR ', $in)); + $where[] = qsprintf($conn, '%LO', $in); break; default: throw new Exception(pht('Unknown phase "%s"!', $phase)); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function buildOrderClause(AphrontDatabaseConnection $conn_w, $phase) { diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php index ae6e2cc442..fa9a521d0f 100644 --- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php +++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php @@ -48,59 +48,59 @@ abstract class PhabricatorWorkerTaskQuery return $this; } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id in (%Ld)', $this->ids); } if ($this->objectPHIDs !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); } if ($this->dateModifiedSince !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'dateModified > %d', $this->dateModifiedSince); } if ($this->dateCreatedBefore !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'dateCreated < %d', $this->dateCreatedBefore); } if ($this->classNames !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'taskClass IN (%Ls)', $this->classNames); } if ($this->minFailureCount !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'failureCount >= %d', $this->minFailureCount); } if ($this->maxFailureCount !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'failureCount <= %d', $this->maxFailureCount); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } protected function buildOrderClause(AphrontDatabaseConnection $conn_r) { diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php index a8dc5061e7..931b09f1f9 100644 --- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php +++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php @@ -160,52 +160,52 @@ final class PhabricatorWorkerTriggerQuery return implode(' ', $joins); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 't.id IN (%Ld)', $this->ids); } if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 't.phid IN (%Ls)', $this->phids); } if ($this->versionMin !== null) { $where[] = qsprintf( - $conn_r, + $conn, 't.triggerVersion >= %d', $this->versionMin); } if ($this->versionMax !== null) { $where[] = qsprintf( - $conn_r, + $conn, 't.triggerVersion <= %d', $this->versionMax); } if ($this->nextEpochMin !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'e.nextEventEpoch >= %d', $this->nextEpochMin); } if ($this->nextEpochMax !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'e.nextEventEpoch <= %d', $this->nextEpochMax); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } private function buildOrderClause(AphrontDatabaseConnection $conn_r) { diff --git a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php index 2dfceb7fbc..edd78c868e 100644 --- a/src/infrastructure/edges/query/PhabricatorEdgeQuery.php +++ b/src/infrastructure/edges/query/PhabricatorEdgeQuery.php @@ -290,19 +290,19 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery { /** * @task internal */ - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { + protected function buildWhereClause(AphrontDatabaseConnection $conn) { $where = array(); if ($this->sourcePHIDs) { $where[] = qsprintf( - $conn_r, + $conn, 'edge.src IN (%Ls)', $this->sourcePHIDs); } if ($this->edgeTypes) { $where[] = qsprintf( - $conn_r, + $conn, 'edge.type IN (%Ls)', $this->edgeTypes); } @@ -310,12 +310,12 @@ final class PhabricatorEdgeQuery extends PhabricatorQuery { if ($this->destPHIDs) { // potentially complain if $this->edgeType was not set $where[] = qsprintf( - $conn_r, + $conn, 'edge.dst IN (%Ls)', $this->destPHIDs); } - return $this->formatWhereClause($where); + return $this->formatWhereClause($conn, $where); } diff --git a/src/infrastructure/query/PhabricatorOffsetPagedQuery.php b/src/infrastructure/query/PhabricatorOffsetPagedQuery.php index ef97a4ebe4..fd9ea18e3f 100644 --- a/src/infrastructure/query/PhabricatorOffsetPagedQuery.php +++ b/src/infrastructure/query/PhabricatorOffsetPagedQuery.php @@ -27,15 +27,15 @@ abstract class PhabricatorOffsetPagedQuery extends PhabricatorQuery { return $this->limit; } - protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { + protected function buildLimitClause(AphrontDatabaseConnection $conn) { 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) { - return qsprintf($conn_r, 'LIMIT %d', $this->limit); + return qsprintf($conn, 'LIMIT %d', $this->limit); } 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 { - return ''; + return qsprintf($conn, ''); } } diff --git a/src/infrastructure/query/PhabricatorQuery.php b/src/infrastructure/query/PhabricatorQuery.php index 1dfe14b6f2..4315ef79ae 100644 --- a/src/infrastructure/query/PhabricatorQuery.php +++ b/src/infrastructure/query/PhabricatorQuery.php @@ -15,28 +15,19 @@ abstract class PhabricatorQuery extends Phobject { /** * @task format */ - protected function formatWhereClause(array $parts) { + protected function formatWhereClause( + AphrontDatabaseConnection $conn, + array $parts) { + $parts = $this->flattenSubclause($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 @@ -57,39 +48,32 @@ abstract class PhabricatorQuery extends Phobject { /** * @task format */ - protected function formatJoinClause(array $parts) { + protected function formatJoinClause( + AphrontDatabaseConnection $conn, + array $parts) { + $parts = $this->flattenSubclause($parts); if (!$parts) { - return ''; + return qsprintf($conn, ''); } - return implode(' ', $parts); + return qsprintf($conn, '%LJ', $parts); } /** * @task format */ - protected function formatHavingClause(array $parts) { + protected function formatHavingClause( + AphrontDatabaseConnection $conn, + array $parts) { + $parts = $this->flattenSubclause($parts); if (!$parts) { - return ''; + return qsprintf($conn, ''); } - return 'HAVING '.$this->formatHavingSubclause($parts); - } - - - /** - * @task format - */ - protected function formatHavingSubclause(array $parts) { - $parts = $this->flattenSubclause($parts); - if (!$parts) { - return null; - } - - return '('.implode(') AND (', $parts).')'; + return qsprintf($conn, 'HAVING %LA', $parts); } diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index cd101a61d9..49ab55ef4f 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -195,15 +195,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery } } - final protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { + final protected function buildLimitClause(AphrontDatabaseConnection $conn) { if ($this->shouldLimitResults()) { $limit = $this->getRawResultLimit(); if ($limit) { - return qsprintf($conn_r, 'LIMIT %d', $limit); + return qsprintf($conn, 'LIMIT %d', $limit); } } - return ''; + return qsprintf($conn, ''); } protected function shouldLimitResults() { @@ -306,7 +306,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery */ protected function buildJoinClause(AphrontDatabaseConnection $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) { $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) { $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) { if (!$this->shouldGroupQueryResultRows()) { - return ''; + return qsprintf($conn, ''); } return qsprintf( $conn, '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 * a table alias. * - * @return string Column name. + * @param AphrontDatabaseConnection Connection executing queries. + * @return PhutilQueryString Column name. * @task appsearch */ - protected function getApplicationSearchObjectPHIDColumn() { - if ($this->getPrimaryTableAlias()) { - $prefix = $this->getPrimaryTableAlias().'.'; - } else { - $prefix = ''; - } + protected function getApplicationSearchObjectPHIDColumn( + AphrontDatabaseConnection $conn) { - 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 */ protected function buildApplicationSearchGroupClause( - AphrontDatabaseConnection $conn_r) { + AphrontDatabaseConnection $conn) { if ($this->getApplicationSearchMayJoinMultipleRows()) { return qsprintf( - $conn_r, + $conn, 'GROUP BY %Q', $this->getApplicationSearchObjectPHIDColumn()); } else { - return ''; + return qsprintf($conn, ''); } } @@ -1410,7 +1411,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery } } - $phid_column = $this->getApplicationSearchObjectPHIDColumn(); + $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn); $orderable = $this->getOrderableColumns(); $vector = $this->getOrderVector(); @@ -2373,7 +2374,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery */ public function buildEdgeLogicJoinClause(AphrontDatabaseConnection $conn) { $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; - $phid_column = $this->getApplicationSearchObjectPHIDColumn(); + $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn); $joins = array(); foreach ($this->edgeLogicConstraints as $type => $constraints) { @@ -2531,9 +2532,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery } if ($full && $null) { - $full = $this->formatWhereSubclause($full); - $null = $this->formatWhereSubclause($null); - $where[] = qsprintf($conn, '(%Q OR %Q)', $full, $null); + $where[] = qsprintf($conn, '(%LA OR %LA)', $full, $null); } else if ($full) { foreach ($full as $condition) { $where[] = $condition; diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 583d8226f6..03dbf51961 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -517,13 +517,14 @@ abstract class LiskDAO extends Phobject protected function loadRawDataWhere($pattern /* , $args... */) { - $connection = $this->establishConnection('r'); + $conn = $this->establishConnection('r'); - $lock_clause = ''; - if ($connection->isReadLocking()) { - $lock_clause = 'FOR UPDATE'; - } else if ($connection->isWriteLocking()) { - $lock_clause = 'LOCK IN SHARE MODE'; + if ($conn->isReadLocking()) { + $lock_clause = qsprintf($conn, 'FOR UPDATE'); + } else if ($conn->isWriteLocking()) { + $lock_clause = qsprintf($conn, 'LOCK IN SHARE MODE'); + } else { + $lock_clause = qsprintf($conn, ''); } $args = func_get_args(); @@ -534,9 +535,7 @@ abstract class LiskDAO extends Phobject array_push($args, $lock_clause); array_unshift($args, $pattern); - return call_user_func_array( - array($connection, 'queryData'), - $args); + return call_user_func_array(array($conn, 'queryData'), $args); }