@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+404 -414
+8 -8
src/applications/auth/query/PhabricatorAuthInviteQuery.php
··· 59 59 return $invites; 60 60 } 61 61 62 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 62 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 63 63 $where = array(); 64 64 65 65 if ($this->ids !== null) { 66 66 $where[] = qsprintf( 67 - $conn_r, 67 + $conn, 68 68 'id IN (%Ld)', 69 69 $this->ids); 70 70 } 71 71 72 72 if ($this->phids !== null) { 73 73 $where[] = qsprintf( 74 - $conn_r, 74 + $conn, 75 75 'phid IN (%Ls)', 76 76 $this->phids); 77 77 } 78 78 79 79 if ($this->emailAddresses !== null) { 80 80 $where[] = qsprintf( 81 - $conn_r, 81 + $conn, 82 82 'emailAddress IN (%Ls)', 83 83 $this->emailAddresses); 84 84 } ··· 90 90 } 91 91 92 92 $where[] = qsprintf( 93 - $conn_r, 93 + $conn, 94 94 'verificationHash IN (%Ls)', 95 95 $hashes); 96 96 } 97 97 98 98 if ($this->authorPHIDs !== null) { 99 99 $where[] = qsprintf( 100 - $conn_r, 100 + $conn, 101 101 'authorPHID IN (%Ls)', 102 102 $this->authorPHIDs); 103 103 } 104 104 105 - $where[] = $this->buildPagingClause($conn_r); 105 + $where[] = $this->buildPagingClause($conn); 106 106 107 - return $this->formatWhereClause($where); 107 + return $this->formatWhereClause($conn, $where); 108 108 } 109 109 110 110 public function getQueryApplicationClass() {
+10 -10
src/applications/auth/query/PhabricatorAuthProviderConfigQuery.php
··· 54 54 return $table->loadAllFromArray($data); 55 55 } 56 56 57 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 57 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 58 58 $where = array(); 59 59 60 - if ($this->ids) { 60 + if ($this->ids !== null) { 61 61 $where[] = qsprintf( 62 - $conn_r, 62 + $conn, 63 63 'id IN (%Ld)', 64 64 $this->ids); 65 65 } 66 66 67 - if ($this->phids) { 67 + if ($this->phids !== null) { 68 68 $where[] = qsprintf( 69 - $conn_r, 69 + $conn, 70 70 'phid IN (%Ls)', 71 71 $this->phids); 72 72 } 73 73 74 - if ($this->providerClasses) { 74 + if ($this->providerClasses !== null) { 75 75 $where[] = qsprintf( 76 - $conn_r, 76 + $conn, 77 77 'providerClass IN (%Ls)', 78 78 $this->providerClasses); 79 79 } ··· 84 84 break; 85 85 case self::STATUS_ENABLED: 86 86 $where[] = qsprintf( 87 - $conn_r, 87 + $conn, 88 88 'isEnabled = 1'); 89 89 break; 90 90 default: 91 91 throw new Exception(pht("Unknown status '%s'!", $status)); 92 92 } 93 93 94 - $where[] = $this->buildPagingClause($conn_r); 94 + $where[] = $this->buildPagingClause($conn); 95 95 96 - return $this->formatWhereClause($where); 96 + return $this->formatWhereClause($conn, $where); 97 97 } 98 98 99 99 public function getQueryApplicationClass() {
+11 -11
src/applications/auth/query/PhabricatorAuthSessionQuery.php
··· 65 65 return $sessions; 66 66 } 67 67 68 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 68 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 69 69 $where = array(); 70 70 71 - if ($this->ids) { 71 + if ($this->ids !== null) { 72 72 $where[] = qsprintf( 73 - $conn_r, 73 + $conn, 74 74 'id IN (%Ld)', 75 75 $this->ids); 76 76 } 77 77 78 - if ($this->identityPHIDs) { 78 + if ($this->identityPHIDs !== null) { 79 79 $where[] = qsprintf( 80 - $conn_r, 80 + $conn, 81 81 'userPHID IN (%Ls)', 82 82 $this->identityPHIDs); 83 83 } 84 84 85 - if ($this->sessionKeys) { 85 + if ($this->sessionKeys !== null) { 86 86 $hashes = array(); 87 87 foreach ($this->sessionKeys as $session_key) { 88 88 $hashes[] = PhabricatorHash::weakDigest($session_key); 89 89 } 90 90 $where[] = qsprintf( 91 - $conn_r, 91 + $conn, 92 92 'sessionKey IN (%Ls)', 93 93 $hashes); 94 94 } 95 95 96 - if ($this->sessionTypes) { 96 + if ($this->sessionTypes !== null) { 97 97 $where[] = qsprintf( 98 - $conn_r, 98 + $conn, 99 99 'type IN (%Ls)', 100 100 $this->sessionTypes); 101 101 } 102 102 103 - $where[] = $this->buildPagingClause($conn_r); 103 + $where[] = $this->buildPagingClause($conn); 104 104 105 - return $this->formatWhereClause($where); 105 + return $this->formatWhereClause($conn, $where); 106 106 } 107 107 108 108 public function getQueryApplicationClass() {
+8 -8
src/applications/calendar/query/PhabricatorCalendarEventInviteeQuery.php
··· 49 49 return $table->loadAllFromArray($data); 50 50 } 51 51 52 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 52 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 53 53 $where = array(); 54 54 55 55 if ($this->ids !== null) { 56 56 $where[] = qsprintf( 57 - $conn_r, 57 + $conn, 58 58 'id IN (%Ld)', 59 59 $this->ids); 60 60 } 61 61 62 62 if ($this->eventPHIDs !== null) { 63 63 $where[] = qsprintf( 64 - $conn_r, 64 + $conn, 65 65 'eventPHID IN (%Ls)', 66 66 $this->eventPHIDs); 67 67 } 68 68 69 69 if ($this->inviteePHIDs !== null) { 70 70 $where[] = qsprintf( 71 - $conn_r, 71 + $conn, 72 72 'inviteePHID IN (%Ls)', 73 73 $this->inviteePHIDs); 74 74 } 75 75 76 76 if ($this->inviterPHIDs !== null) { 77 77 $where[] = qsprintf( 78 - $conn_r, 78 + $conn, 79 79 'inviterPHID IN (%Ls)', 80 80 $this->inviterPHIDs); 81 81 } 82 82 83 83 if ($this->statuses !== null) { 84 84 $where[] = qsprintf( 85 - $conn_r, 85 + $conn, 86 86 'status = %d', 87 87 $this->statuses); 88 88 } 89 89 90 - $where[] = $this->buildPagingClause($conn_r); 90 + $where[] = $this->buildPagingClause($conn); 91 91 92 - return $this->formatWhereClause($where); 92 + return $this->formatWhereClause($conn, $where); 93 93 } 94 94 95 95 public function getQueryApplicationClass() {
-4
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
··· 509 509 return parent::shouldGroupQueryResultRows(); 510 510 } 511 511 512 - protected function getApplicationSearchObjectPHIDColumn() { 513 - return 'event.phid'; 514 - } 515 - 516 512 public function getQueryApplicationClass() { 517 513 return 'PhabricatorCalendarApplication'; 518 514 }
+5 -5
src/applications/chatlog/query/PhabricatorChatLogChannelQuery.php
··· 33 33 return $logs; 34 34 } 35 35 36 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 36 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 37 37 $where = array(); 38 38 39 - $where[] = $this->buildPagingClause($conn_r); 39 + $where[] = $this->buildPagingClause($conn); 40 40 41 41 if ($this->channelIDs) { 42 42 $where[] = qsprintf( 43 - $conn_r, 43 + $conn, 44 44 'id IN (%Ld)', 45 45 $this->channelIDs); 46 46 ··· 48 48 49 49 if ($this->channels) { 50 50 $where[] = qsprintf( 51 - $conn_r, 51 + $conn, 52 52 'channelName IN (%Ls)', 53 53 $this->channels); 54 54 } 55 55 56 - return $this->formatWhereClause($where); 56 + return $this->formatWhereClause($conn, $where); 57 57 } 58 58 59 59 public function getQueryApplicationClass() {
+7 -7
src/applications/chatlog/query/PhabricatorChatLogQuery.php
··· 55 55 return $events; 56 56 } 57 57 58 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 58 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 59 59 $where = array(); 60 60 61 - $where[] = $this->buildPagingClause($conn_r); 61 + $where[] = $this->buildPagingClause($conn); 62 62 63 - if ($this->maximumEpoch) { 63 + if ($this->maximumEpoch !== null) { 64 64 $where[] = qsprintf( 65 - $conn_r, 65 + $conn, 66 66 'epoch <= %d', 67 67 $this->maximumEpoch); 68 68 } 69 69 70 - if ($this->channelIDs) { 70 + if ($this->channelIDs !== null) { 71 71 $where[] = qsprintf( 72 - $conn_r, 72 + $conn, 73 73 'channelID IN (%Ld)', 74 74 $this->channelIDs); 75 75 } 76 76 77 - return $this->formatWhereClause($where); 77 + return $this->formatWhereClause($conn, $where); 78 78 } 79 79 80 80 public function getQueryApplicationClass() {
+7 -7
src/applications/config/query/PhabricatorConfigEntryQuery.php
··· 31 31 return $table->loadAllFromArray($data); 32 32 } 33 33 34 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 34 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 35 35 $where = array(); 36 36 37 - if ($this->ids) { 37 + if ($this->ids !== null) { 38 38 $where[] = qsprintf( 39 - $conn_r, 39 + $conn, 40 40 'id IN (%Ld)', 41 41 $this->ids); 42 42 } 43 43 44 - if ($this->phids) { 44 + if ($this->phids !== null) { 45 45 $where[] = qsprintf( 46 - $conn_r, 46 + $conn, 47 47 'phid IN (%Ls)', 48 48 $this->phids); 49 49 } 50 50 51 - $where[] = $this->buildPagingClause($conn_r); 51 + $where[] = $this->buildPagingClause($conn); 52 52 53 - return $this->formatWhereClause($where); 53 + return $this->formatWhereClause($conn, $where); 54 54 } 55 55 56 56 public function getQueryApplicationClass() {
+5 -5
src/applications/conpherence/query/ConpherenceFulltextQuery.php
··· 38 38 return $rows; 39 39 } 40 40 41 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 41 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 42 42 $where = array(); 43 43 44 44 if ($this->threadPHIDs !== null) { 45 45 $where[] = qsprintf( 46 - $conn_r, 46 + $conn, 47 47 'i.threadPHID IN (%Ls)', 48 48 $this->threadPHIDs); 49 49 } 50 50 51 51 if ($this->previousTransactionPHIDs !== null) { 52 52 $where[] = qsprintf( 53 - $conn_r, 53 + $conn, 54 54 'i.previousTransactionPHID IN (%Ls)', 55 55 $this->previousTransactionPHIDs); 56 56 } ··· 61 61 $compiled_query = $compiler->compileQuery($tokens); 62 62 63 63 $where[] = qsprintf( 64 - $conn_r, 64 + $conn, 65 65 'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)', 66 66 $compiled_query); 67 67 } 68 68 69 - return $this->formatWhereClause($where); 69 + return $this->formatWhereClause($conn, $where); 70 70 } 71 71 72 72 private function buildOrderByClause(AphrontDatabaseConnection $conn_r) {
+1 -1
src/applications/conpherence/query/ConpherenceParticipantCountQuery.php
··· 57 57 } 58 58 } 59 59 60 - return $this->formatWhereClause($where); 60 + return $this->formatWhereClause($conn, $where); 61 61 } 62 62 63 63 private function buildGroupByClause(AphrontDatabaseConnection $conn) {
+1 -1
src/applications/conpherence/query/ConpherenceParticipantQuery.php
··· 38 38 $this->participantPHIDs); 39 39 } 40 40 41 - return $this->formatWhereClause($where); 41 + return $this->formatWhereClause($conn, $where); 42 42 } 43 43 44 44 private function buildOrderClause(AphrontDatabaseConnection $conn) {
+9 -8
src/applications/daemon/query/PhabricatorDaemonLogQuery.php
··· 124 124 return $daemons; 125 125 } 126 126 127 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 127 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 128 128 $where = array(); 129 129 130 130 if ($this->ids !== null) { 131 131 $where[] = qsprintf( 132 - $conn_r, 132 + $conn, 133 133 'id IN (%Ld)', 134 134 $this->ids); 135 135 } 136 136 137 137 if ($this->notIDs !== null) { 138 138 $where[] = qsprintf( 139 - $conn_r, 139 + $conn, 140 140 'id NOT IN (%Ld)', 141 141 $this->notIDs); 142 142 } 143 143 144 144 if ($this->getStatusConstants()) { 145 145 $where[] = qsprintf( 146 - $conn_r, 146 + $conn, 147 147 'status IN (%Ls)', 148 148 $this->getStatusConstants()); 149 149 } 150 150 151 151 if ($this->daemonClasses !== null) { 152 152 $where[] = qsprintf( 153 - $conn_r, 153 + $conn, 154 154 'daemon IN (%Ls)', 155 155 $this->daemonClasses); 156 156 } 157 157 158 158 if ($this->daemonIDs !== null) { 159 159 $where[] = qsprintf( 160 - $conn_r, 160 + $conn, 161 161 'daemonID IN (%Ls)', 162 162 $this->daemonIDs); 163 163 } 164 164 165 - $where[] = $this->buildPagingClause($conn_r); 166 - return $this->formatWhereClause($where); 165 + $where[] = $this->buildPagingClause($conn); 166 + 167 + return $this->formatWhereClause($conn, $where); 167 168 } 168 169 169 170 private function getStatusConstants() {
+10 -10
src/applications/differential/query/DifferentialInlineCommentQuery.php
··· 107 107 return head($this->execute()); 108 108 } 109 109 110 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 110 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 111 111 $where = array(); 112 112 113 113 // Only find inline comments. 114 114 $where[] = qsprintf( 115 - $conn_r, 115 + $conn, 116 116 'changesetID IS NOT NULL'); 117 117 118 118 if ($this->ids !== null) { 119 119 $where[] = qsprintf( 120 - $conn_r, 120 + $conn, 121 121 'id IN (%Ld)', 122 122 $this->ids); 123 123 } 124 124 125 125 if ($this->phids !== null) { 126 126 $where[] = qsprintf( 127 - $conn_r, 127 + $conn, 128 128 'phid IN (%Ls)', 129 129 $this->phids); 130 130 } 131 131 132 132 if ($this->revisionPHIDs !== null) { 133 133 $where[] = qsprintf( 134 - $conn_r, 134 + $conn, 135 135 'revisionPHID IN (%Ls)', 136 136 $this->revisionPHIDs); 137 137 } ··· 139 139 if ($this->drafts === null) { 140 140 if ($this->deletedDrafts) { 141 141 $where[] = qsprintf( 142 - $conn_r, 142 + $conn, 143 143 '(authorPHID = %s) OR (transactionPHID IS NOT NULL)', 144 144 $this->getViewer()->getPHID()); 145 145 } else { 146 146 $where[] = qsprintf( 147 - $conn_r, 147 + $conn, 148 148 '(authorPHID = %s AND isDeleted = 0) 149 149 OR (transactionPHID IS NOT NULL)', 150 150 $this->getViewer()->getPHID()); 151 151 } 152 152 } else if ($this->drafts) { 153 153 $where[] = qsprintf( 154 - $conn_r, 154 + $conn, 155 155 '(authorPHID = %s AND isDeleted = 0) AND (transactionPHID IS NULL)', 156 156 $this->getViewer()->getPHID()); 157 157 } else { 158 158 $where[] = qsprintf( 159 - $conn_r, 159 + $conn, 160 160 'transactionPHID IS NOT NULL'); 161 161 } 162 162 163 - return $this->formatWhereClause($where); 163 + return $this->formatWhereClause($conn, $where); 164 164 } 165 165 166 166 public function adjustInlinesForChangesets(
+29 -28
src/applications/differential/query/DifferentialRevisionQuery.php
··· 542 542 /** 543 543 * @task internal 544 544 */ 545 - private function buildJoinsClause($conn_r) { 545 + private function buildJoinsClause(AphrontDatabaseConnection $conn) { 546 546 $joins = array(); 547 547 if ($this->pathIDs) { 548 548 $path_table = new DifferentialAffectedPath(); 549 549 $joins[] = qsprintf( 550 - $conn_r, 550 + $conn, 551 551 'JOIN %T p ON p.revisionID = r.id', 552 552 $path_table->getTableName()); 553 553 } 554 554 555 555 if ($this->commitHashes) { 556 556 $joins[] = qsprintf( 557 - $conn_r, 557 + $conn, 558 558 'JOIN %T hash_rel ON hash_rel.revisionID = r.id', 559 559 ArcanistDifferentialRevisionHash::TABLE_NAME); 560 560 } 561 561 562 562 if ($this->ccs) { 563 563 $joins[] = qsprintf( 564 - $conn_r, 564 + $conn, 565 565 'JOIN %T e_ccs ON e_ccs.src = r.phid '. 566 566 'AND e_ccs.type = %s '. 567 567 'AND e_ccs.dst in (%Ls)', ··· 572 572 573 573 if ($this->reviewers) { 574 574 $joins[] = qsprintf( 575 - $conn_r, 575 + $conn, 576 576 'JOIN %T reviewer ON reviewer.revisionPHID = r.phid 577 577 AND reviewer.reviewerStatus != %s 578 578 AND reviewer.reviewerPHID in (%Ls)', ··· 583 583 584 584 if ($this->draftAuthors) { 585 585 $joins[] = qsprintf( 586 - $conn_r, 586 + $conn, 587 587 'JOIN %T has_draft ON has_draft.srcPHID = r.phid 588 588 AND has_draft.type = %s 589 589 AND has_draft.dstPHID IN (%Ls)', ··· 594 594 595 595 if ($this->commitPHIDs) { 596 596 $joins[] = qsprintf( 597 - $conn_r, 597 + $conn, 598 598 'JOIN %T commits ON commits.revisionID = r.id', 599 599 DifferentialRevision::TABLE_COMMIT); 600 600 } 601 601 602 - $joins[] = $this->buildJoinClauseParts($conn_r); 602 + $joins[] = $this->buildJoinClauseParts($conn); 603 603 604 - return $this->formatJoinClause($joins); 604 + return $this->formatJoinClause($conn, $joins); 605 605 } 606 606 607 607 608 608 /** 609 609 * @task internal 610 610 */ 611 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 611 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 612 612 $where = array(); 613 613 614 614 if ($this->pathIDs) { ··· 616 616 $repo_info = igroup($this->pathIDs, 'repositoryID'); 617 617 foreach ($repo_info as $repository_id => $paths) { 618 618 $path_clauses[] = qsprintf( 619 - $conn_r, 619 + $conn, 620 620 '(p.repositoryID = %d AND p.pathID IN (%Ld))', 621 621 $repository_id, 622 622 ipull($paths, 'pathID')); 623 623 } 624 - $path_clauses = '('.implode(' OR ', $path_clauses).')'; 624 + $path_clauses = qsprintf($conn, '%LO', $path_clauses); 625 625 $where[] = $path_clauses; 626 626 } 627 627 628 628 if ($this->authors) { 629 629 $where[] = qsprintf( 630 - $conn_r, 630 + $conn, 631 631 'r.authorPHID IN (%Ls)', 632 632 $this->authors); 633 633 } 634 634 635 635 if ($this->revIDs) { 636 636 $where[] = qsprintf( 637 - $conn_r, 637 + $conn, 638 638 'r.id IN (%Ld)', 639 639 $this->revIDs); 640 640 } 641 641 642 642 if ($this->repositoryPHIDs) { 643 643 $where[] = qsprintf( 644 - $conn_r, 644 + $conn, 645 645 'r.repositoryPHID IN (%Ls)', 646 646 $this->repositoryPHIDs); 647 647 } ··· 651 651 foreach ($this->commitHashes as $info) { 652 652 list($type, $hash) = $info; 653 653 $hash_clauses[] = qsprintf( 654 - $conn_r, 654 + $conn, 655 655 '(hash_rel.type = %s AND hash_rel.hash = %s)', 656 656 $type, 657 657 $hash); 658 658 } 659 - $hash_clauses = '('.implode(' OR ', $hash_clauses).')'; 659 + $hash_clauses = qsprintf($conn, '%LO', $hash_clauses); 660 660 $where[] = $hash_clauses; 661 661 } 662 662 663 663 if ($this->commitPHIDs) { 664 664 $where[] = qsprintf( 665 - $conn_r, 665 + $conn, 666 666 'commits.commitPHID IN (%Ls)', 667 667 $this->commitPHIDs); 668 668 } 669 669 670 670 if ($this->phids) { 671 671 $where[] = qsprintf( 672 - $conn_r, 672 + $conn, 673 673 'r.phid IN (%Ls)', 674 674 $this->phids); 675 675 } 676 676 677 677 if ($this->branches) { 678 678 $where[] = qsprintf( 679 - $conn_r, 679 + $conn, 680 680 'r.branchName in (%Ls)', 681 681 $this->branches); 682 682 } 683 683 684 684 if ($this->updatedEpochMin !== null) { 685 685 $where[] = qsprintf( 686 - $conn_r, 686 + $conn, 687 687 'r.dateModified >= %d', 688 688 $this->updatedEpochMin); 689 689 } 690 690 691 691 if ($this->updatedEpochMax !== null) { 692 692 $where[] = qsprintf( 693 - $conn_r, 693 + $conn, 694 694 'r.dateModified <= %d', 695 695 $this->updatedEpochMax); 696 696 } 697 697 698 698 if ($this->createdEpochMin !== null) { 699 699 $where[] = qsprintf( 700 - $conn_r, 700 + $conn, 701 701 'r.dateCreated >= %d', 702 702 $this->createdEpochMin); 703 703 } 704 704 705 705 if ($this->createdEpochMax !== null) { 706 706 $where[] = qsprintf( 707 - $conn_r, 707 + $conn, 708 708 'r.dateCreated <= %d', 709 709 $this->createdEpochMax); 710 710 } 711 711 712 712 if ($this->statuses !== null) { 713 713 $where[] = qsprintf( 714 - $conn_r, 714 + $conn, 715 715 'r.status in (%Ls)', 716 716 $this->statuses); 717 717 } ··· 725 725 DifferentialLegacyQuery::STATUS_CLOSED); 726 726 } 727 727 $where[] = qsprintf( 728 - $conn_r, 728 + $conn, 729 729 'r.status in (%Ls)', 730 730 $statuses); 731 731 } 732 732 733 - $where[] = $this->buildWhereClauseParts($conn_r); 734 - return $this->formatWhereClause($where); 733 + $where[] = $this->buildWhereClauseParts($conn); 734 + 735 + return $this->formatWhereClause($conn, $where); 735 736 } 736 737 737 738
+4 -4
src/applications/diffusion/query/DiffusionLintCountQuery.php
··· 70 70 } 71 71 72 72 protected function buildCustomWhereClause( 73 - AphrontDatabaseConnection $conn_r, 73 + AphrontDatabaseConnection $conn, 74 74 $part) { 75 75 76 76 $where = array(); ··· 79 79 80 80 if ($this->codes !== null) { 81 81 $where[] = qsprintf( 82 - $conn_r, 82 + $conn, 83 83 'code IN (%Ls)', 84 84 $this->codes); 85 85 } 86 86 87 87 if ($this->branchIDs !== null) { 88 88 $where[] = qsprintf( 89 - $conn_r, 89 + $conn, 90 90 'branchID IN (%Ld)', 91 91 $this->branchIDs); 92 92 } 93 93 94 - return $this->formatWhereClause($where); 94 + return $this->formatWhereClause($conn, $where); 95 95 } 96 96 97 97 private function processPaths() {
+8 -8
src/applications/diffusion/query/DiffusionSymbolQuery.php
··· 192 192 /** 193 193 * @task internal 194 194 */ 195 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 195 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 196 196 $where = array(); 197 197 198 198 if (isset($this->context)) { 199 199 $where[] = qsprintf( 200 - $conn_r, 200 + $conn, 201 201 'symbolContext = %s', 202 202 $this->context); 203 203 } 204 204 205 205 if ($this->name) { 206 206 $where[] = qsprintf( 207 - $conn_r, 207 + $conn, 208 208 'symbolName = %s', 209 209 $this->name); 210 210 } 211 211 212 212 if ($this->namePrefix) { 213 213 $where[] = qsprintf( 214 - $conn_r, 214 + $conn, 215 215 'symbolName LIKE %>', 216 216 $this->namePrefix); 217 217 } 218 218 219 219 if ($this->repositoryPHIDs) { 220 220 $where[] = qsprintf( 221 - $conn_r, 221 + $conn, 222 222 'repositoryPHID IN (%Ls)', 223 223 $this->repositoryPHIDs); 224 224 } 225 225 226 226 if ($this->language) { 227 227 $where[] = qsprintf( 228 - $conn_r, 228 + $conn, 229 229 'symbolLanguage = %s', 230 230 $this->language); 231 231 } 232 232 233 233 if ($this->type) { 234 234 $where[] = qsprintf( 235 - $conn_r, 235 + $conn, 236 236 'symbolType = %s', 237 237 $this->type); 238 238 } 239 239 240 - return $this->formatWhereClause($where); 240 + return $this->formatWhereClause($conn, $where); 241 241 } 242 242 243 243
+19 -19
src/applications/diviner/query/DivinerAtomQuery.php
··· 299 299 return $atoms; 300 300 } 301 301 302 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 302 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 303 303 $where = array(); 304 304 305 305 if ($this->ids) { 306 306 $where[] = qsprintf( 307 - $conn_r, 307 + $conn, 308 308 'id IN (%Ld)', 309 309 $this->ids); 310 310 } 311 311 312 312 if ($this->phids) { 313 313 $where[] = qsprintf( 314 - $conn_r, 314 + $conn, 315 315 'phid IN (%Ls)', 316 316 $this->phids); 317 317 } 318 318 319 319 if ($this->bookPHIDs) { 320 320 $where[] = qsprintf( 321 - $conn_r, 321 + $conn, 322 322 'bookPHID IN (%Ls)', 323 323 $this->bookPHIDs); 324 324 } 325 325 326 326 if ($this->types) { 327 327 $where[] = qsprintf( 328 - $conn_r, 328 + $conn, 329 329 'type IN (%Ls)', 330 330 $this->types); 331 331 } 332 332 333 333 if ($this->names) { 334 334 $where[] = qsprintf( 335 - $conn_r, 335 + $conn, 336 336 'name IN (%Ls)', 337 337 $this->names); 338 338 } ··· 347 347 } 348 348 349 349 $where[] = qsprintf( 350 - $conn_r, 350 + $conn, 351 351 'titleSlugHash in (%Ls)', 352 352 $hashes); 353 353 } ··· 366 366 367 367 if ($contexts && $with_null) { 368 368 $where[] = qsprintf( 369 - $conn_r, 369 + $conn, 370 370 'context IN (%Ls) OR context IS NULL', 371 371 $contexts); 372 372 } else if ($contexts) { 373 373 $where[] = qsprintf( 374 - $conn_r, 374 + $conn, 375 375 'context IN (%Ls)', 376 376 $contexts); 377 377 } else if ($with_null) { 378 378 $where[] = qsprintf( 379 - $conn_r, 379 + $conn, 380 380 'context IS NULL'); 381 381 } 382 382 } 383 383 384 384 if ($this->indexes) { 385 385 $where[] = qsprintf( 386 - $conn_r, 386 + $conn, 387 387 'atomIndex IN (%Ld)', 388 388 $this->indexes); 389 389 } 390 390 391 391 if ($this->isDocumentable !== null) { 392 392 $where[] = qsprintf( 393 - $conn_r, 393 + $conn, 394 394 'isDocumentable = %d', 395 395 (int)$this->isDocumentable); 396 396 } 397 397 398 398 if ($this->isGhost !== null) { 399 399 if ($this->isGhost) { 400 - $where[] = qsprintf($conn_r, 'graphHash IS NULL'); 400 + $where[] = qsprintf($conn, 'graphHash IS NULL'); 401 401 } else { 402 - $where[] = qsprintf($conn_r, 'graphHash IS NOT NULL'); 402 + $where[] = qsprintf($conn, 'graphHash IS NOT NULL'); 403 403 } 404 404 } 405 405 406 406 if ($this->nodeHashes) { 407 407 $where[] = qsprintf( 408 - $conn_r, 408 + $conn, 409 409 'nodeHash IN (%Ls)', 410 410 $this->nodeHashes); 411 411 } ··· 415 415 // the column has binary collation. Eventually, this should move into 416 416 // fulltext. 417 417 $where[] = qsprintf( 418 - $conn_r, 418 + $conn, 419 419 'CONVERT(name USING utf8) LIKE %~', 420 420 $this->nameContains); 421 421 } 422 422 423 423 if ($this->repositoryPHIDs) { 424 424 $where[] = qsprintf( 425 - $conn_r, 425 + $conn, 426 426 'repositoryPHID IN (%Ls)', 427 427 $this->repositoryPHIDs); 428 428 } 429 429 430 - $where[] = $this->buildPagingClause($conn_r); 430 + $where[] = $this->buildPagingClause($conn); 431 431 432 - return $this->formatWhereClause($where); 432 + return $this->formatWhereClause($conn, $where); 433 433 } 434 434 435 435 /**
+9 -9
src/applications/diviner/query/DivinerBookQuery.php
··· 116 116 return $books; 117 117 } 118 118 119 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 119 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 120 120 $where = array(); 121 121 122 122 if ($this->ids) { 123 123 $where[] = qsprintf( 124 - $conn_r, 124 + $conn, 125 125 'id IN (%Ld)', 126 126 $this->ids); 127 127 } 128 128 129 129 if ($this->phids) { 130 130 $where[] = qsprintf( 131 - $conn_r, 131 + $conn, 132 132 'phid IN (%Ls)', 133 133 $this->phids); 134 134 } 135 135 136 136 if (strlen($this->nameLike)) { 137 137 $where[] = qsprintf( 138 - $conn_r, 138 + $conn, 139 139 'name LIKE %~', 140 140 $this->nameLike); 141 141 } 142 142 143 143 if ($this->names !== null) { 144 144 $where[] = qsprintf( 145 - $conn_r, 145 + $conn, 146 146 'name IN (%Ls)', 147 147 $this->names); 148 148 } 149 149 150 150 if (strlen($this->namePrefix)) { 151 151 $where[] = qsprintf( 152 - $conn_r, 152 + $conn, 153 153 'name LIKE %>', 154 154 $this->namePrefix); 155 155 } 156 156 157 157 if ($this->repositoryPHIDs !== null) { 158 158 $where[] = qsprintf( 159 - $conn_r, 159 + $conn, 160 160 'repositoryPHID IN (%Ls)', 161 161 $this->repositoryPHIDs); 162 162 } 163 163 164 - $where[] = $this->buildPagingClause($conn_r); 164 + $where[] = $this->buildPagingClause($conn); 165 165 166 - return $this->formatWhereClause($where); 166 + return $this->formatWhereClause($conn, $where); 167 167 } 168 168 169 169 public function getQueryApplicationClass() {
+8 -8
src/applications/files/query/PhabricatorFileChunkQuery.php
··· 86 86 return $chunks; 87 87 } 88 88 89 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 89 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 90 90 $where = array(); 91 91 92 92 if ($this->chunkHandles !== null) { 93 93 $where[] = qsprintf( 94 - $conn_r, 94 + $conn, 95 95 'chunkHandle IN (%Ls)', 96 96 $this->chunkHandles); 97 97 } 98 98 99 99 if ($this->rangeStart !== null) { 100 100 $where[] = qsprintf( 101 - $conn_r, 101 + $conn, 102 102 'byteEnd > %d', 103 103 $this->rangeStart); 104 104 } 105 105 106 106 if ($this->rangeEnd !== null) { 107 107 $where[] = qsprintf( 108 - $conn_r, 108 + $conn, 109 109 'byteStart < %d', 110 110 $this->rangeEnd); 111 111 } ··· 113 113 if ($this->isComplete !== null) { 114 114 if ($this->isComplete) { 115 115 $where[] = qsprintf( 116 - $conn_r, 116 + $conn, 117 117 'dataFilePHID IS NOT NULL'); 118 118 } else { 119 119 $where[] = qsprintf( 120 - $conn_r, 120 + $conn, 121 121 'dataFilePHID IS NULL'); 122 122 } 123 123 } 124 124 125 - $where[] = $this->buildPagingClause($conn_r); 125 + $where[] = $this->buildPagingClause($conn); 126 126 127 - return $this->formatWhereClause($where); 127 + return $this->formatWhereClause($conn, $where); 128 128 } 129 129 130 130 public function getQueryApplicationClass() {
+7 -7
src/applications/flag/query/PhabricatorFlagQuery.php
··· 123 123 return $flags; 124 124 } 125 125 126 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 126 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 127 127 $where = array(); 128 128 129 129 if ($this->ownerPHIDs) { 130 130 $where[] = qsprintf( 131 - $conn_r, 131 + $conn, 132 132 'flag.ownerPHID IN (%Ls)', 133 133 $this->ownerPHIDs); 134 134 } 135 135 136 136 if ($this->types) { 137 137 $where[] = qsprintf( 138 - $conn_r, 138 + $conn, 139 139 'flag.type IN (%Ls)', 140 140 $this->types); 141 141 } 142 142 143 143 if ($this->objectPHIDs) { 144 144 $where[] = qsprintf( 145 - $conn_r, 145 + $conn, 146 146 'flag.objectPHID IN (%Ls)', 147 147 $this->objectPHIDs); 148 148 } 149 149 150 150 if ($this->colors) { 151 151 $where[] = qsprintf( 152 - $conn_r, 152 + $conn, 153 153 'flag.color IN (%Ld)', 154 154 $this->colors); 155 155 } 156 156 157 - $where[] = $this->buildPagingClause($conn_r); 157 + $where[] = $this->buildPagingClause($conn); 158 158 159 - return $this->formatWhereClause($where); 159 + return $this->formatWhereClause($conn, $where); 160 160 } 161 161 162 162 public function getQueryApplicationClass() {
+8 -8
src/applications/fund/query/FundBackerQuery.php
··· 68 68 return $backers; 69 69 } 70 70 71 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 71 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 72 72 $where = array(); 73 73 74 - $where[] = $this->buildPagingClause($conn_r); 74 + $where[] = $this->buildPagingClause($conn); 75 75 76 76 if ($this->ids !== null) { 77 77 $where[] = qsprintf( 78 - $conn_r, 78 + $conn, 79 79 'id IN (%Ld)', 80 80 $this->ids); 81 81 } 82 82 83 83 if ($this->phids !== null) { 84 84 $where[] = qsprintf( 85 - $conn_r, 85 + $conn, 86 86 'phid IN (%Ls)', 87 87 $this->phids); 88 88 } 89 89 90 90 if ($this->initiativePHIDs !== null) { 91 91 $where[] = qsprintf( 92 - $conn_r, 92 + $conn, 93 93 'initiativePHID IN (%Ls)', 94 94 $this->initiativePHIDs); 95 95 } 96 96 97 97 if ($this->backerPHIDs !== null) { 98 98 $where[] = qsprintf( 99 - $conn_r, 99 + $conn, 100 100 'backerPHID IN (%Ls)', 101 101 $this->backerPHIDs); 102 102 } 103 103 104 104 if ($this->statuses !== null) { 105 105 $where[] = qsprintf( 106 - $conn_r, 106 + $conn, 107 107 'status IN (%Ls)', 108 108 $this->statuses); 109 109 } 110 110 111 - return $this->formatWhereClause($where); 111 + return $this->formatWhereClause($conn, $where); 112 112 } 113 113 114 114 public function getQueryApplicationClass() {
+11 -11
src/applications/herald/query/HeraldRuleQuery.php
··· 175 175 return $rules; 176 176 } 177 177 178 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 178 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 179 179 $where = array(); 180 180 181 181 if ($this->ids) { 182 182 $where[] = qsprintf( 183 - $conn_r, 183 + $conn, 184 184 'rule.id IN (%Ld)', 185 185 $this->ids); 186 186 } 187 187 188 188 if ($this->phids) { 189 189 $where[] = qsprintf( 190 - $conn_r, 190 + $conn, 191 191 'rule.phid IN (%Ls)', 192 192 $this->phids); 193 193 } 194 194 195 195 if ($this->authorPHIDs) { 196 196 $where[] = qsprintf( 197 - $conn_r, 197 + $conn, 198 198 'rule.authorPHID IN (%Ls)', 199 199 $this->authorPHIDs); 200 200 } 201 201 202 202 if ($this->ruleTypes) { 203 203 $where[] = qsprintf( 204 - $conn_r, 204 + $conn, 205 205 'rule.ruleType IN (%Ls)', 206 206 $this->ruleTypes); 207 207 } 208 208 209 209 if ($this->contentTypes) { 210 210 $where[] = qsprintf( 211 - $conn_r, 211 + $conn, 212 212 'rule.contentType IN (%Ls)', 213 213 $this->contentTypes); 214 214 } 215 215 216 216 if ($this->disabled !== null) { 217 217 $where[] = qsprintf( 218 - $conn_r, 218 + $conn, 219 219 'rule.isDisabled = %d', 220 220 (int)$this->disabled); 221 221 } 222 222 223 223 if ($this->datasourceQuery) { 224 224 $where[] = qsprintf( 225 - $conn_r, 225 + $conn, 226 226 'rule.name LIKE %>', 227 227 $this->datasourceQuery); 228 228 } 229 229 230 230 if ($this->triggerObjectPHIDs) { 231 231 $where[] = qsprintf( 232 - $conn_r, 232 + $conn, 233 233 'rule.triggerObjectPHID IN (%Ls)', 234 234 $this->triggerObjectPHIDs); 235 235 } 236 236 237 - $where[] = $this->buildPagingClause($conn_r); 237 + $where[] = $this->buildPagingClause($conn); 238 238 239 - return $this->formatWhereClause($where); 239 + return $this->formatWhereClause($conn, $where); 240 240 } 241 241 242 242 private function validateRuleAuthors(array $rules) {
+6 -6
src/applications/herald/query/HeraldTranscriptQuery.php
··· 91 91 return $transcripts; 92 92 } 93 93 94 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 94 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 95 95 $where = array(); 96 96 97 97 if ($this->ids) { 98 98 $where[] = qsprintf( 99 - $conn_r, 99 + $conn, 100 100 'id IN (%Ld)', 101 101 $this->ids); 102 102 } 103 103 104 104 if ($this->phids) { 105 105 $where[] = qsprintf( 106 - $conn_r, 106 + $conn, 107 107 'phid IN (%Ls)', 108 108 $this->phids); 109 109 } 110 110 111 111 if ($this->objectPHIDs) { 112 112 $where[] = qsprintf( 113 - $conn_r, 113 + $conn, 114 114 'objectPHID in (%Ls)', 115 115 $this->objectPHIDs); 116 116 } 117 117 118 - $where[] = $this->buildPagingClause($conn_r); 118 + $where[] = $this->buildPagingClause($conn); 119 119 120 - return $this->formatWhereClause($where); 120 + return $this->formatWhereClause($conn, $where); 121 121 } 122 122 123 123 public function getQueryApplicationClass() {
+10 -10
src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php
··· 86 86 return $signatures; 87 87 } 88 88 89 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 89 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 90 90 $where = array(); 91 91 92 - $where[] = $this->buildPagingClause($conn_r); 92 + $where[] = $this->buildPagingClause($conn); 93 93 94 94 if ($this->ids !== null) { 95 95 $where[] = qsprintf( 96 - $conn_r, 96 + $conn, 97 97 'id IN (%Ld)', 98 98 $this->ids); 99 99 } 100 100 101 101 if ($this->documentPHIDs !== null) { 102 102 $where[] = qsprintf( 103 - $conn_r, 103 + $conn, 104 104 'documentPHID IN (%Ls)', 105 105 $this->documentPHIDs); 106 106 } 107 107 108 108 if ($this->signerPHIDs !== null) { 109 109 $where[] = qsprintf( 110 - $conn_r, 110 + $conn, 111 111 'signerPHID IN (%Ls)', 112 112 $this->signerPHIDs); 113 113 } 114 114 115 115 if ($this->documentVersions !== null) { 116 116 $where[] = qsprintf( 117 - $conn_r, 117 + $conn, 118 118 'documentVersion IN (%Ld)', 119 119 $this->documentVersions); 120 120 } 121 121 122 122 if ($this->secretKeys !== null) { 123 123 $where[] = qsprintf( 124 - $conn_r, 124 + $conn, 125 125 'secretKey IN (%Ls)', 126 126 $this->secretKeys); 127 127 } 128 128 129 129 if ($this->nameContains !== null) { 130 130 $where[] = qsprintf( 131 - $conn_r, 131 + $conn, 132 132 'signerName LIKE %~', 133 133 $this->nameContains); 134 134 } 135 135 136 136 if ($this->emailContains !== null) { 137 137 $where[] = qsprintf( 138 - $conn_r, 138 + $conn, 139 139 'signerEmail LIKE %~', 140 140 $this->emailContains); 141 141 } 142 142 143 - return $this->formatWhereClause($where); 143 + return $this->formatWhereClause($conn, $where); 144 144 } 145 145 146 146 public function getQueryApplicationClass() {
+6 -6
src/applications/oauthserver/query/PhabricatorOAuthServerClientQuery.php
··· 37 37 return $table->loadAllFromArray($data); 38 38 } 39 39 40 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 40 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 41 41 $where = array(); 42 42 43 43 if ($this->ids) { 44 44 $where[] = qsprintf( 45 - $conn_r, 45 + $conn, 46 46 'id IN (%Ld)', 47 47 $this->ids); 48 48 } 49 49 50 50 if ($this->phids) { 51 51 $where[] = qsprintf( 52 - $conn_r, 52 + $conn, 53 53 'phid IN (%Ls)', 54 54 $this->phids); 55 55 } 56 56 57 57 if ($this->creatorPHIDs) { 58 58 $where[] = qsprintf( 59 - $conn_r, 59 + $conn, 60 60 'creatorPHID IN (%Ls)', 61 61 $this->creatorPHIDs); 62 62 } 63 63 64 - $where[] = $this->buildPagingClause($conn_r); 64 + $where[] = $this->buildPagingClause($conn); 65 65 66 - return $this->formatWhereClause($where); 66 + return $this->formatWhereClause($conn, $where); 67 67 } 68 68 69 69 public function getQueryApplicationClass() {
+6 -6
src/applications/phlux/query/PhluxVariableQuery.php
··· 37 37 return $table->loadAllFromArray($rows); 38 38 } 39 39 40 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 40 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 41 41 $where = array(); 42 42 43 43 if ($this->ids !== null) { 44 44 $where[] = qsprintf( 45 - $conn_r, 45 + $conn, 46 46 'id IN (%Ld)', 47 47 $this->ids); 48 48 } 49 49 50 50 if ($this->keys !== null) { 51 51 $where[] = qsprintf( 52 - $conn_r, 52 + $conn, 53 53 'variableKey IN (%Ls)', 54 54 $this->keys); 55 55 } 56 56 57 57 if ($this->phids !== null) { 58 58 $where[] = qsprintf( 59 - $conn_r, 59 + $conn, 60 60 'phid IN (%Ls)', 61 61 $this->phids); 62 62 } 63 63 64 - $where[] = $this->buildPagingClause($conn_r); 64 + $where[] = $this->buildPagingClause($conn); 65 65 66 - return $this->formatWhereClause($where); 66 + return $this->formatWhereClause($conn, $where); 67 67 } 68 68 69 69 protected function getDefaultOrderVector() {
+7 -7
src/applications/pholio/query/PholioImageQuery.php
··· 61 61 return $images; 62 62 } 63 63 64 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 64 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 65 65 $where = array(); 66 66 67 - $where[] = $this->buildPagingClause($conn_r); 67 + $where[] = $this->buildPagingClause($conn); 68 68 69 69 if ($this->ids) { 70 70 $where[] = qsprintf( 71 - $conn_r, 71 + $conn, 72 72 'id IN (%Ld)', 73 73 $this->ids); 74 74 } 75 75 76 76 if ($this->phids) { 77 77 $where[] = qsprintf( 78 - $conn_r, 78 + $conn, 79 79 'phid IN (%Ls)', 80 80 $this->phids); 81 81 } 82 82 83 83 if ($this->mockIDs) { 84 84 $where[] = qsprintf( 85 - $conn_r, 85 + $conn, 86 86 'mockID IN (%Ld)', 87 87 $this->mockIDs); 88 88 } 89 89 90 90 if ($this->obsolete !== null) { 91 91 $where[] = qsprintf( 92 - $conn_r, 92 + $conn, 93 93 'isObsolete = %d', 94 94 $this->obsolete); 95 95 } 96 96 97 - return $this->formatWhereClause($where); 97 + return $this->formatWhereClause($conn, $where); 98 98 } 99 99 100 100 protected function willFilterPage(array $images) {
+1 -1
src/applications/phortune/query/PhortuneAccountQuery.php
··· 99 99 $this->memberPHIDs); 100 100 } 101 101 102 - return $this->formatWhereClause($where); 102 + return $this->formatWhereClause($conn, $where); 103 103 } 104 104 105 105 protected function buildJoinClause(AphrontDatabaseConnection $conn) {
+1 -1
src/applications/phortune/query/PhortuneCartQuery.php
··· 213 213 } 214 214 } 215 215 216 - return $this->formatWhereClause($where); 216 + return $this->formatWhereClause($conn, $where); 217 217 } 218 218 219 219 public function getQueryApplicationClass() {
+1 -1
src/applications/phortune/query/PhortuneChargeQuery.php
··· 134 134 $this->statuses); 135 135 } 136 136 137 - return $this->formatWhereClause($where); 137 + return $this->formatWhereClause($conn, $where); 138 138 } 139 139 140 140 public function getQueryApplicationClass() {
+1 -1
src/applications/phortune/query/PhortuneMerchantQuery.php
··· 114 114 115 115 $where[] = $this->buildPagingClause($conn); 116 116 117 - return $this->formatWhereClause($where); 117 + return $this->formatWhereClause($conn, $where); 118 118 } 119 119 120 120 protected function buildJoinClause(AphrontDatabaseConnection $conn) {
+1 -1
src/applications/phortune/query/PhortunePaymentProviderConfigQuery.php
··· 85 85 86 86 $where[] = $this->buildPagingClause($conn); 87 87 88 - return $this->formatWhereClause($where); 88 + return $this->formatWhereClause($conn, $where); 89 89 } 90 90 91 91 public function getQueryApplicationClass() {
+2 -2
src/applications/phortune/query/PhortuneProductQuery.php
··· 105 105 PhabricatorHash::digestForIndex($ref)); 106 106 } 107 107 } 108 - $where[] = implode(' OR ', $sql); 108 + $where[] = qsprintf($conn, '%LO', $sql); 109 109 } 110 110 111 111 $where[] = $this->buildPagingClause($conn); 112 112 113 - return $this->formatWhereClause($where); 113 + return $this->formatWhereClause($conn, $where); 114 114 } 115 115 116 116 public function getQueryApplicationClass() {
+1 -1
src/applications/phortune/query/PhortunePurchaseQuery.php
··· 100 100 $this->cartPHIDs); 101 101 } 102 102 103 - return $this->formatWhereClause($where); 103 + return $this->formatWhereClause($conn, $where); 104 104 } 105 105 106 106 public function getQueryApplicationClass() {
+1 -1
src/applications/phortune/query/PhortuneSubscriptionQuery.php
··· 182 182 $this->statuses); 183 183 } 184 184 185 - return $this->formatWhereClause($where); 185 + return $this->formatWhereClause($conn, $where); 186 186 } 187 187 188 188 public function getQueryApplicationClass() {
+8 -8
src/applications/phragment/query/PhragmentFragmentQuery.php
··· 55 55 return $table->loadAllFromArray($data); 56 56 } 57 57 58 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 58 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 59 59 $where = array(); 60 60 61 61 if ($this->ids) { 62 62 $where[] = qsprintf( 63 - $conn_r, 63 + $conn, 64 64 'id IN (%Ld)', 65 65 $this->ids); 66 66 } 67 67 68 68 if ($this->phids) { 69 69 $where[] = qsprintf( 70 - $conn_r, 70 + $conn, 71 71 'phid IN (%Ls)', 72 72 $this->phids); 73 73 } 74 74 75 75 if ($this->paths) { 76 76 $where[] = qsprintf( 77 - $conn_r, 77 + $conn, 78 78 'path IN (%Ls)', 79 79 $this->paths); 80 80 } 81 81 82 82 if ($this->leadingPath) { 83 83 $where[] = qsprintf( 84 - $conn_r, 84 + $conn, 85 85 'path LIKE %>', 86 86 $this->leadingPath); 87 87 } 88 88 89 89 if ($this->depths) { 90 90 $where[] = qsprintf( 91 - $conn_r, 91 + $conn, 92 92 'depth IN (%Ld)', 93 93 $this->depths); 94 94 } 95 95 96 - $where[] = $this->buildPagingClause($conn_r); 96 + $where[] = $this->buildPagingClause($conn); 97 97 98 - return $this->formatWhereClause($where); 98 + return $this->formatWhereClause($conn, $where); 99 99 } 100 100 101 101 protected function didFilterPage(array $page) {
+8 -8
src/applications/phragment/query/PhragmentFragmentVersionQuery.php
··· 49 49 return $table->loadAllFromArray($data); 50 50 } 51 51 52 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 52 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 53 53 $where = array(); 54 54 55 55 if ($this->ids) { 56 56 $where[] = qsprintf( 57 - $conn_r, 57 + $conn, 58 58 'id IN (%Ld)', 59 59 $this->ids); 60 60 } 61 61 62 62 if ($this->phids) { 63 63 $where[] = qsprintf( 64 - $conn_r, 64 + $conn, 65 65 'phid IN (%Ls)', 66 66 $this->phids); 67 67 } 68 68 69 69 if ($this->fragmentPHIDs) { 70 70 $where[] = qsprintf( 71 - $conn_r, 71 + $conn, 72 72 'fragmentPHID IN (%Ls)', 73 73 $this->fragmentPHIDs); 74 74 } 75 75 76 76 if ($this->sequences) { 77 77 $where[] = qsprintf( 78 - $conn_r, 78 + $conn, 79 79 'sequence IN (%Ld)', 80 80 $this->sequences); 81 81 } 82 82 83 83 if ($this->sequenceBefore !== null) { 84 84 $where[] = qsprintf( 85 - $conn_r, 85 + $conn, 86 86 'sequence < %d', 87 87 $this->sequenceBefore); 88 88 } 89 89 90 - $where[] = $this->buildPagingClause($conn_r); 90 + $where[] = $this->buildPagingClause($conn); 91 91 92 - return $this->formatWhereClause($where); 92 + return $this->formatWhereClause($conn, $where); 93 93 } 94 94 95 95 protected function willFilterPage(array $page) {
+7 -7
src/applications/phragment/query/PhragmentSnapshotChildQuery.php
··· 55 55 return $table->loadAllFromArray($data); 56 56 } 57 57 58 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 58 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 59 59 $where = array(); 60 60 61 61 if ($this->ids) { 62 62 $where[] = qsprintf( 63 - $conn_r, 63 + $conn, 64 64 'id IN (%Ld)', 65 65 $this->ids); 66 66 } 67 67 68 68 if ($this->snapshotPHIDs) { 69 69 $where[] = qsprintf( 70 - $conn_r, 70 + $conn, 71 71 'snapshotPHID IN (%Ls)', 72 72 $this->snapshotPHIDs); 73 73 } 74 74 75 75 if ($this->fragmentPHIDs) { 76 76 $where[] = qsprintf( 77 - $conn_r, 77 + $conn, 78 78 'fragmentPHID IN (%Ls)', 79 79 $this->fragmentPHIDs); 80 80 } 81 81 82 82 if ($this->fragmentVersionPHIDs) { 83 83 $where[] = qsprintf( 84 - $conn_r, 84 + $conn, 85 85 'fragmentVersionPHID IN (%Ls)', 86 86 $this->fragmentVersionPHIDs); 87 87 } 88 88 89 - $where[] = $this->buildPagingClause($conn_r); 89 + $where[] = $this->buildPagingClause($conn); 90 90 91 - return $this->formatWhereClause($where); 91 + return $this->formatWhereClause($conn, $where); 92 92 } 93 93 94 94 protected function willFilterPage(array $page) {
+11 -11
src/applications/phragment/query/PhragmentSnapshotQuery.php
··· 43 43 return $table->loadAllFromArray($data); 44 44 } 45 45 46 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 46 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 47 47 $where = array(); 48 48 49 - if ($this->ids) { 49 + if ($this->ids !== null) { 50 50 $where[] = qsprintf( 51 - $conn_r, 51 + $conn, 52 52 'id IN (%Ld)', 53 53 $this->ids); 54 54 } 55 55 56 - if ($this->phids) { 56 + if ($this->phids !== null) { 57 57 $where[] = qsprintf( 58 - $conn_r, 58 + $conn, 59 59 'phid IN (%Ls)', 60 60 $this->phids); 61 61 } 62 62 63 - if ($this->primaryFragmentPHIDs) { 63 + if ($this->primaryFragmentPHIDs !== null) { 64 64 $where[] = qsprintf( 65 - $conn_r, 65 + $conn, 66 66 'primaryFragmentPHID IN (%Ls)', 67 67 $this->primaryFragmentPHIDs); 68 68 } 69 69 70 - if ($this->names) { 70 + if ($this->names !== null) { 71 71 $where[] = qsprintf( 72 - $conn_r, 72 + $conn, 73 73 'name IN (%Ls)', 74 74 $this->names); 75 75 } 76 76 77 - $where[] = $this->buildPagingClause($conn_r); 77 + $where[] = $this->buildPagingClause($conn); 78 78 79 - return $this->formatWhereClause($where); 79 + return $this->formatWhereClause($conn, $where); 80 80 } 81 81 82 82 protected function willFilterPage(array $page) {
+1 -1
src/applications/phrequent/query/PhrequentUserTimeQuery.php
··· 116 116 117 117 $where[] = $this->buildPagingClause($conn); 118 118 119 - return $this->formatWhereClause($where); 119 + return $this->formatWhereClause($conn, $where); 120 120 } 121 121 122 122 public function getOrderableColumns() {
+7 -7
src/applications/releeph/query/ReleephBranchQuery.php
··· 103 103 return $branches; 104 104 } 105 105 106 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 106 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 107 107 $where = array(); 108 108 109 109 if ($this->ids !== null) { 110 110 $where[] = qsprintf( 111 - $conn_r, 111 + $conn, 112 112 'id IN (%Ld)', 113 113 $this->ids); 114 114 } 115 115 116 116 if ($this->phids !== null) { 117 117 $where[] = qsprintf( 118 - $conn_r, 118 + $conn, 119 119 'phid IN (%Ls)', 120 120 $this->phids); 121 121 } 122 122 123 123 if ($this->productIDs !== null) { 124 124 $where[] = qsprintf( 125 - $conn_r, 125 + $conn, 126 126 'releephProjectID IN (%Ld)', 127 127 $this->productIDs); 128 128 } ··· 133 133 break; 134 134 case self::STATUS_OPEN: 135 135 $where[] = qsprintf( 136 - $conn_r, 136 + $conn, 137 137 'isActive = 1'); 138 138 break; 139 139 default: 140 140 throw new Exception(pht("Unknown status constant '%s'!", $status)); 141 141 } 142 142 143 - $where[] = $this->buildPagingClause($conn_r); 143 + $where[] = $this->buildPagingClause($conn); 144 144 145 - return $this->formatWhereClause($where); 145 + return $this->formatWhereClause($conn, $where); 146 146 } 147 147 148 148 public function getQueryApplicationClass() {
+7 -7
src/applications/releeph/query/ReleephProductQuery.php
··· 83 83 return $projects; 84 84 } 85 85 86 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 86 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 87 87 $where = array(); 88 88 89 89 if ($this->active !== null) { 90 90 $where[] = qsprintf( 91 - $conn_r, 91 + $conn, 92 92 'isActive = %d', 93 93 (int)$this->active); 94 94 } 95 95 96 96 if ($this->ids !== null) { 97 97 $where[] = qsprintf( 98 - $conn_r, 98 + $conn, 99 99 'id IN (%Ls)', 100 100 $this->ids); 101 101 } 102 102 103 103 if ($this->phids !== null) { 104 104 $where[] = qsprintf( 105 - $conn_r, 105 + $conn, 106 106 'phid IN (%Ls)', 107 107 $this->phids); 108 108 } 109 109 110 110 if ($this->repositoryPHIDs !== null) { 111 111 $where[] = qsprintf( 112 - $conn_r, 112 + $conn, 113 113 'repositoryPHID IN (%Ls)', 114 114 $this->repositoryPHIDs); 115 115 } 116 116 117 - $where[] = $this->buildPagingClause($conn_r); 117 + $where[] = $this->buildPagingClause($conn); 118 118 119 - return $this->formatWhereClause($where); 119 + return $this->formatWhereClause($conn, $where); 120 120 } 121 121 122 122 public function getOrderableColumns() {
+9 -9
src/applications/releeph/query/ReleephRequestQuery.php
··· 147 147 return $requests; 148 148 } 149 149 150 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 150 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 151 151 $where = array(); 152 152 153 153 if ($this->ids !== null) { 154 154 $where[] = qsprintf( 155 - $conn_r, 155 + $conn, 156 156 'id IN (%Ld)', 157 157 $this->ids); 158 158 } 159 159 160 160 if ($this->phids !== null) { 161 161 $where[] = qsprintf( 162 - $conn_r, 162 + $conn, 163 163 'phid IN (%Ls)', 164 164 $this->phids); 165 165 } 166 166 167 167 if ($this->branchIDs !== null) { 168 168 $where[] = qsprintf( 169 - $conn_r, 169 + $conn, 170 170 'branchID IN (%Ld)', 171 171 $this->branchIDs); 172 172 } 173 173 174 174 if ($this->requestedCommitPHIDs !== null) { 175 175 $where[] = qsprintf( 176 - $conn_r, 176 + $conn, 177 177 'requestCommitPHID IN (%Ls)', 178 178 $this->requestedCommitPHIDs); 179 179 } 180 180 181 181 if ($this->requestorPHIDs !== null) { 182 182 $where[] = qsprintf( 183 - $conn_r, 183 + $conn, 184 184 'requestUserPHID IN (%Ls)', 185 185 $this->requestorPHIDs); 186 186 } 187 187 188 188 if ($this->requestedObjectPHIDs !== null) { 189 189 $where[] = qsprintf( 190 - $conn_r, 190 + $conn, 191 191 'requestedObjectPHID IN (%Ls)', 192 192 $this->requestedObjectPHIDs); 193 193 } 194 194 195 - $where[] = $this->buildPagingClause($conn_r); 195 + $where[] = $this->buildPagingClause($conn); 196 196 197 - return $this->formatWhereClause($where); 197 + return $this->formatWhereClause($conn, $where); 198 198 } 199 199 200 200 private function getKeepStatusConstants() {
+6 -6
src/applications/search/query/PhabricatorSavedQueryQuery.php
··· 37 37 return $table->loadAllFromArray($data); 38 38 } 39 39 40 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 40 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 41 41 $where = array(); 42 42 43 43 if ($this->ids !== null) { 44 44 $where[] = qsprintf( 45 - $conn_r, 45 + $conn, 46 46 'id IN (%Ld)', 47 47 $this->ids); 48 48 } 49 49 50 50 if ($this->engineClassNames !== null) { 51 51 $where[] = qsprintf( 52 - $conn_r, 52 + $conn, 53 53 'engineClassName IN (%Ls)', 54 54 $this->engineClassNames); 55 55 } 56 56 57 57 if ($this->queryKeys !== null) { 58 58 $where[] = qsprintf( 59 - $conn_r, 59 + $conn, 60 60 'queryKey IN (%Ls)', 61 61 $this->queryKeys); 62 62 } 63 63 64 - $where[] = $this->buildPagingClause($conn_r); 64 + $where[] = $this->buildPagingClause($conn); 65 65 66 - return $this->formatWhereClause($where); 66 + return $this->formatWhereClause($conn, $where); 67 67 } 68 68 69 69 public function getQueryApplicationClass() {
+3 -3
src/applications/tokens/query/PhabricatorTokenCountQuery.php
··· 24 24 return ipull($rows, 'tokenCount', 'objectPHID'); 25 25 } 26 26 27 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 27 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 28 28 $where = array(); 29 29 30 30 if ($this->objectPHIDs) { 31 31 $where[] = qsprintf( 32 - $conn_r, 32 + $conn, 33 33 'objectPHID IN (%Ls)', 34 34 $this->objectPHIDs); 35 35 } 36 36 37 - return $this->formatWhereClause($where); 37 + return $this->formatWhereClause($conn, $where); 38 38 } 39 39 40 40 }
+12 -10
src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
··· 57 57 return $table->loadAllFromArray($data); 58 58 } 59 59 60 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 61 - return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r)); 60 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 61 + return $this->formatWhereClause( 62 + $conn, 63 + $this->buildWhereClauseComponents($conn)); 62 64 } 63 65 64 66 protected function buildWhereClauseComponents( 65 - AphrontDatabaseConnection $conn_r) { 67 + AphrontDatabaseConnection $conn) { 66 68 67 69 $where = array(); 68 70 69 71 if ($this->ids !== null) { 70 72 $where[] = qsprintf( 71 - $conn_r, 73 + $conn, 72 74 'xcomment.id IN (%Ld)', 73 75 $this->ids); 74 76 } 75 77 76 78 if ($this->phids !== null) { 77 79 $where[] = qsprintf( 78 - $conn_r, 80 + $conn, 79 81 'xcomment.phid IN (%Ls)', 80 82 $this->phids); 81 83 } 82 84 83 85 if ($this->authorPHIDs !== null) { 84 86 $where[] = qsprintf( 85 - $conn_r, 87 + $conn, 86 88 'xcomment.authorPHID IN (%Ls)', 87 89 $this->authorPHIDs); 88 90 } 89 91 90 92 if ($this->transactionPHIDs !== null) { 91 93 $where[] = qsprintf( 92 - $conn_r, 94 + $conn, 93 95 'xcomment.transactionPHID IN (%Ls)', 94 96 $this->transactionPHIDs); 95 97 } 96 98 97 99 if ($this->isDeleted !== null) { 98 100 $where[] = qsprintf( 99 - $conn_r, 101 + $conn, 100 102 'xcomment.isDeleted = %d', 101 103 (int)$this->isDeleted); 102 104 } ··· 104 106 if ($this->hasTransaction !== null) { 105 107 if ($this->hasTransaction) { 106 108 $where[] = qsprintf( 107 - $conn_r, 109 + $conn, 108 110 'xcomment.transactionPHID IS NOT NULL'); 109 111 } else { 110 112 $where[] = qsprintf( 111 - $conn_r, 113 + $conn, 112 114 'xcomment.transactionPHID IS NULL'); 113 115 } 114 116 }
+22 -14
src/infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php
··· 209 209 } 210 210 211 211 protected function buildCustomWhereClause( 212 - AphrontDatabaseConnection $conn_w, 212 + AphrontDatabaseConnection $conn, 213 213 $phase) { 214 214 215 215 $where = array(); 216 216 217 217 switch ($phase) { 218 218 case self::PHASE_LEASED: 219 - $where[] = 'leaseOwner IS NOT NULL'; 220 - $where[] = 'leaseExpires >= UNIX_TIMESTAMP()'; 219 + $where[] = qsprintf( 220 + $conn, 221 + 'leaseOwner IS NOT NULL'); 222 + $where[] = qsprintf( 223 + $conn, 224 + 'leaseExpires >= UNIX_TIMESTAMP()'); 221 225 break; 222 226 case self::PHASE_UNLEASED: 223 - $where[] = 'leaseOwner IS NULL'; 227 + $where[] = qsprintf( 228 + $conn, 229 + 'leaseOwner IS NULL'); 224 230 break; 225 231 case self::PHASE_EXPIRED: 226 - $where[] = 'leaseExpires < UNIX_TIMESTAMP()'; 232 + $where[] = qsprintf( 233 + $conn, 234 + 'leaseExpires < UNIX_TIMESTAMP()'); 227 235 break; 228 236 default: 229 237 throw new Exception(pht("Unknown phase '%s'!", $phase)); 230 238 } 231 239 232 240 if ($this->ids !== null) { 233 - $where[] = qsprintf($conn_w, 'id IN (%Ld)', $this->ids); 241 + $where[] = qsprintf($conn, 'id IN (%Ld)', $this->ids); 234 242 } 235 243 236 244 if ($this->objectPHIDs !== null) { 237 - $where[] = qsprintf($conn_w, 'objectPHID IN (%Ls)', $this->objectPHIDs); 245 + $where[] = qsprintf($conn, 'objectPHID IN (%Ls)', $this->objectPHIDs); 238 246 } 239 247 240 - return $this->formatWhereClause($where); 248 + return $this->formatWhereClause($conn, $where); 241 249 } 242 250 243 251 private function buildUpdateWhereClause( 244 - AphrontDatabaseConnection $conn_w, 252 + AphrontDatabaseConnection $conn, 245 253 $phase, 246 254 array $rows) { 247 255 ··· 257 265 'Trying to lease tasks selected in the leased phase! This is '. 258 266 'intended to be impossible.')); 259 267 case self::PHASE_UNLEASED: 260 - $where[] = qsprintf($conn_w, 'leaseOwner IS NULL'); 261 - $where[] = qsprintf($conn_w, 'id IN (%Ld)', ipull($rows, 'id')); 268 + $where[] = qsprintf($conn, 'leaseOwner IS NULL'); 269 + $where[] = qsprintf($conn, 'id IN (%Ld)', ipull($rows, 'id')); 262 270 break; 263 271 case self::PHASE_EXPIRED: 264 272 $in = array(); 265 273 foreach ($rows as $row) { 266 274 $in[] = qsprintf( 267 - $conn_w, 275 + $conn, 268 276 '(id = %d AND leaseOwner = %s)', 269 277 $row['id'], 270 278 $row['leaseOwner']); 271 279 } 272 - $where[] = qsprintf($conn_w, '(%Q)', implode(' OR ', $in)); 280 + $where[] = qsprintf($conn, '%LO', $in); 273 281 break; 274 282 default: 275 283 throw new Exception(pht('Unknown phase "%s"!', $phase)); 276 284 } 277 285 278 - return $this->formatWhereClause($where); 286 + return $this->formatWhereClause($conn, $where); 279 287 } 280 288 281 289 private function buildOrderClause(AphrontDatabaseConnection $conn_w, $phase) {
+9 -9
src/infrastructure/daemon/workers/query/PhabricatorWorkerTaskQuery.php
··· 48 48 return $this; 49 49 } 50 50 51 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 51 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 52 52 $where = array(); 53 53 54 54 if ($this->ids !== null) { 55 55 $where[] = qsprintf( 56 - $conn_r, 56 + $conn, 57 57 'id in (%Ld)', 58 58 $this->ids); 59 59 } 60 60 61 61 if ($this->objectPHIDs !== null) { 62 62 $where[] = qsprintf( 63 - $conn_r, 63 + $conn, 64 64 'objectPHID IN (%Ls)', 65 65 $this->objectPHIDs); 66 66 } 67 67 68 68 if ($this->dateModifiedSince !== null) { 69 69 $where[] = qsprintf( 70 - $conn_r, 70 + $conn, 71 71 'dateModified > %d', 72 72 $this->dateModifiedSince); 73 73 } 74 74 75 75 if ($this->dateCreatedBefore !== null) { 76 76 $where[] = qsprintf( 77 - $conn_r, 77 + $conn, 78 78 'dateCreated < %d', 79 79 $this->dateCreatedBefore); 80 80 } 81 81 82 82 if ($this->classNames !== null) { 83 83 $where[] = qsprintf( 84 - $conn_r, 84 + $conn, 85 85 'taskClass IN (%Ls)', 86 86 $this->classNames); 87 87 } 88 88 89 89 if ($this->minFailureCount !== null) { 90 90 $where[] = qsprintf( 91 - $conn_r, 91 + $conn, 92 92 'failureCount >= %d', 93 93 $this->minFailureCount); 94 94 } 95 95 96 96 if ($this->maxFailureCount !== null) { 97 97 $where[] = qsprintf( 98 - $conn_r, 98 + $conn, 99 99 'failureCount <= %d', 100 100 $this->maxFailureCount); 101 101 } 102 102 103 - return $this->formatWhereClause($where); 103 + return $this->formatWhereClause($conn, $where); 104 104 } 105 105 106 106 protected function buildOrderClause(AphrontDatabaseConnection $conn_r) {
+8 -8
src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php
··· 160 160 return implode(' ', $joins); 161 161 } 162 162 163 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 163 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 164 164 $where = array(); 165 165 166 166 if ($this->ids !== null) { 167 167 $where[] = qsprintf( 168 - $conn_r, 168 + $conn, 169 169 't.id IN (%Ld)', 170 170 $this->ids); 171 171 } 172 172 173 173 if ($this->phids !== null) { 174 174 $where[] = qsprintf( 175 - $conn_r, 175 + $conn, 176 176 't.phid IN (%Ls)', 177 177 $this->phids); 178 178 } 179 179 180 180 if ($this->versionMin !== null) { 181 181 $where[] = qsprintf( 182 - $conn_r, 182 + $conn, 183 183 't.triggerVersion >= %d', 184 184 $this->versionMin); 185 185 } 186 186 187 187 if ($this->versionMax !== null) { 188 188 $where[] = qsprintf( 189 - $conn_r, 189 + $conn, 190 190 't.triggerVersion <= %d', 191 191 $this->versionMax); 192 192 } 193 193 194 194 if ($this->nextEpochMin !== null) { 195 195 $where[] = qsprintf( 196 - $conn_r, 196 + $conn, 197 197 'e.nextEventEpoch >= %d', 198 198 $this->nextEpochMin); 199 199 } 200 200 201 201 if ($this->nextEpochMax !== null) { 202 202 $where[] = qsprintf( 203 - $conn_r, 203 + $conn, 204 204 'e.nextEventEpoch <= %d', 205 205 $this->nextEpochMax); 206 206 } 207 207 208 - return $this->formatWhereClause($where); 208 + return $this->formatWhereClause($conn, $where); 209 209 } 210 210 211 211 private function buildOrderClause(AphrontDatabaseConnection $conn_r) {
+5 -5
src/infrastructure/edges/query/PhabricatorEdgeQuery.php
··· 290 290 /** 291 291 * @task internal 292 292 */ 293 - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { 293 + protected function buildWhereClause(AphrontDatabaseConnection $conn) { 294 294 $where = array(); 295 295 296 296 if ($this->sourcePHIDs) { 297 297 $where[] = qsprintf( 298 - $conn_r, 298 + $conn, 299 299 'edge.src IN (%Ls)', 300 300 $this->sourcePHIDs); 301 301 } 302 302 303 303 if ($this->edgeTypes) { 304 304 $where[] = qsprintf( 305 - $conn_r, 305 + $conn, 306 306 'edge.type IN (%Ls)', 307 307 $this->edgeTypes); 308 308 } ··· 310 310 if ($this->destPHIDs) { 311 311 // potentially complain if $this->edgeType was not set 312 312 $where[] = qsprintf( 313 - $conn_r, 313 + $conn, 314 314 'edge.dst IN (%Ls)', 315 315 $this->destPHIDs); 316 316 } 317 317 318 - return $this->formatWhereClause($where); 318 + return $this->formatWhereClause($conn, $where); 319 319 } 320 320 321 321
+5 -5
src/infrastructure/query/PhabricatorOffsetPagedQuery.php
··· 27 27 return $this->limit; 28 28 } 29 29 30 - protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { 30 + protected function buildLimitClause(AphrontDatabaseConnection $conn) { 31 31 if ($this->limit && $this->offset) { 32 - return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, $this->limit); 32 + return qsprintf($conn, 'LIMIT %d, %d', $this->offset, $this->limit); 33 33 } else if ($this->limit) { 34 - return qsprintf($conn_r, 'LIMIT %d', $this->limit); 34 + return qsprintf($conn, 'LIMIT %d', $this->limit); 35 35 } else if ($this->offset) { 36 - return qsprintf($conn_r, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX); 36 + return qsprintf($conn, 'LIMIT %d, %d', $this->offset, PHP_INT_MAX); 37 37 } else { 38 - return ''; 38 + return qsprintf($conn, ''); 39 39 } 40 40 } 41 41
+17 -33
src/infrastructure/query/PhabricatorQuery.php
··· 15 15 /** 16 16 * @task format 17 17 */ 18 - protected function formatWhereClause(array $parts) { 18 + protected function formatWhereClause( 19 + AphrontDatabaseConnection $conn, 20 + array $parts) { 21 + 19 22 $parts = $this->flattenSubclause($parts); 20 23 if (!$parts) { 21 - return ''; 24 + return qsprintf($conn, ''); 22 25 } 23 26 24 - return 'WHERE '.$this->formatWhereSubclause($parts); 27 + return qsprintf($conn, 'WHERE %LA', $parts); 25 28 } 26 29 27 30 28 - /** 29 - * @task format 30 - */ 31 - protected function formatWhereSubclause(array $parts) { 32 - $parts = $this->flattenSubclause($parts); 33 - if (!$parts) { 34 - return null; 35 - } 36 - 37 - return '('.implode(') AND (', $parts).')'; 38 - } 39 - 40 31 41 32 /** 42 33 * @task format ··· 57 48 /** 58 49 * @task format 59 50 */ 60 - protected function formatJoinClause(array $parts) { 61 - $parts = $this->flattenSubclause($parts); 62 - if (!$parts) { 63 - return ''; 64 - } 65 - 66 - return implode(' ', $parts); 67 - } 51 + protected function formatJoinClause( 52 + AphrontDatabaseConnection $conn, 53 + array $parts) { 68 54 69 - 70 - /** 71 - * @task format 72 - */ 73 - protected function formatHavingClause(array $parts) { 74 55 $parts = $this->flattenSubclause($parts); 75 56 if (!$parts) { 76 - return ''; 57 + return qsprintf($conn, ''); 77 58 } 78 59 79 - return 'HAVING '.$this->formatHavingSubclause($parts); 60 + return qsprintf($conn, '%LJ', $parts); 80 61 } 81 62 82 63 83 64 /** 84 65 * @task format 85 66 */ 86 - protected function formatHavingSubclause(array $parts) { 67 + protected function formatHavingClause( 68 + AphrontDatabaseConnection $conn, 69 + array $parts) { 70 + 87 71 $parts = $this->flattenSubclause($parts); 88 72 if (!$parts) { 89 - return null; 73 + return qsprintf($conn, ''); 90 74 } 91 75 92 - return '('.implode(') AND (', $parts).')'; 76 + return qsprintf($conn, 'HAVING %LA', $parts); 93 77 } 94 78 95 79
+22 -23
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 195 195 } 196 196 } 197 197 198 - final protected function buildLimitClause(AphrontDatabaseConnection $conn_r) { 198 + final protected function buildLimitClause(AphrontDatabaseConnection $conn) { 199 199 if ($this->shouldLimitResults()) { 200 200 $limit = $this->getRawResultLimit(); 201 201 if ($limit) { 202 - return qsprintf($conn_r, 'LIMIT %d', $limit); 202 + return qsprintf($conn, 'LIMIT %d', $limit); 203 203 } 204 204 } 205 205 206 - return ''; 206 + return qsprintf($conn, ''); 207 207 } 208 208 209 209 protected function shouldLimitResults() { ··· 306 306 */ 307 307 protected function buildJoinClause(AphrontDatabaseConnection $conn) { 308 308 $joins = $this->buildJoinClauseParts($conn); 309 - return $this->formatJoinClause($joins); 309 + return $this->formatJoinClause($conn, $joins); 310 310 } 311 311 312 312 ··· 328 328 */ 329 329 protected function buildWhereClause(AphrontDatabaseConnection $conn) { 330 330 $where = $this->buildWhereClauseParts($conn); 331 - return $this->formatWhereClause($where); 331 + return $this->formatWhereClause($conn, $where); 332 332 } 333 333 334 334 ··· 352 352 */ 353 353 protected function buildHavingClause(AphrontDatabaseConnection $conn) { 354 354 $having = $this->buildHavingClauseParts($conn); 355 - return $this->formatHavingClause($having); 355 + return $this->formatHavingClause($conn, $having); 356 356 } 357 357 358 358 ··· 371 371 */ 372 372 protected function buildGroupClause(AphrontDatabaseConnection $conn) { 373 373 if (!$this->shouldGroupQueryResultRows()) { 374 - return ''; 374 + return qsprintf($conn, ''); 375 375 } 376 376 377 377 return qsprintf( 378 378 $conn, 379 379 'GROUP BY %Q', 380 - $this->getApplicationSearchObjectPHIDColumn()); 380 + $this->getApplicationSearchObjectPHIDColumn($conn)); 381 381 } 382 382 383 383 ··· 1134 1134 } 1135 1135 } 1136 1136 1137 - return qsprintf($conn, 'ORDER BY %Q', implode(', ', $sql)); 1137 + return qsprintf($conn, 'ORDER BY %LQ', $sql); 1138 1138 } 1139 1139 1140 1140 ··· 1244 1244 * See @{method:getPrimaryTableAlias} if the column needs to be qualified with 1245 1245 * a table alias. 1246 1246 * 1247 - * @return string Column name. 1247 + * @param AphrontDatabaseConnection Connection executing queries. 1248 + * @return PhutilQueryString Column name. 1248 1249 * @task appsearch 1249 1250 */ 1250 - protected function getApplicationSearchObjectPHIDColumn() { 1251 + protected function getApplicationSearchObjectPHIDColumn( 1252 + AphrontDatabaseConnection $conn) { 1253 + 1251 1254 if ($this->getPrimaryTableAlias()) { 1252 - $prefix = $this->getPrimaryTableAlias().'.'; 1255 + return qsprintf($conn, '%T.phid', $this->getPrimaryTableAlias()); 1253 1256 } else { 1254 - $prefix = ''; 1257 + return qsprintf($conn, 'phid'); 1255 1258 } 1256 - 1257 - return $prefix.'phid'; 1258 1259 } 1259 1260 1260 1261 ··· 1308 1309 * @task appsearch 1309 1310 */ 1310 1311 protected function buildApplicationSearchGroupClause( 1311 - AphrontDatabaseConnection $conn_r) { 1312 + AphrontDatabaseConnection $conn) { 1312 1313 1313 1314 if ($this->getApplicationSearchMayJoinMultipleRows()) { 1314 1315 return qsprintf( 1315 - $conn_r, 1316 + $conn, 1316 1317 'GROUP BY %Q', 1317 1318 $this->getApplicationSearchObjectPHIDColumn()); 1318 1319 } else { 1319 - return ''; 1320 + return qsprintf($conn, ''); 1320 1321 } 1321 1322 } 1322 1323 ··· 1410 1411 } 1411 1412 } 1412 1413 1413 - $phid_column = $this->getApplicationSearchObjectPHIDColumn(); 1414 + $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn); 1414 1415 $orderable = $this->getOrderableColumns(); 1415 1416 1416 1417 $vector = $this->getOrderVector(); ··· 2373 2374 */ 2374 2375 public function buildEdgeLogicJoinClause(AphrontDatabaseConnection $conn) { 2375 2376 $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; 2376 - $phid_column = $this->getApplicationSearchObjectPHIDColumn(); 2377 + $phid_column = $this->getApplicationSearchObjectPHIDColumn($conn); 2377 2378 2378 2379 $joins = array(); 2379 2380 foreach ($this->edgeLogicConstraints as $type => $constraints) { ··· 2531 2532 } 2532 2533 2533 2534 if ($full && $null) { 2534 - $full = $this->formatWhereSubclause($full); 2535 - $null = $this->formatWhereSubclause($null); 2536 - $where[] = qsprintf($conn, '(%Q OR %Q)', $full, $null); 2535 + $where[] = qsprintf($conn, '(%LA OR %LA)', $full, $null); 2537 2536 } else if ($full) { 2538 2537 foreach ($full as $condition) { 2539 2538 $where[] = $condition;
+8 -9
src/infrastructure/storage/lisk/LiskDAO.php
··· 517 517 518 518 519 519 protected function loadRawDataWhere($pattern /* , $args... */) { 520 - $connection = $this->establishConnection('r'); 520 + $conn = $this->establishConnection('r'); 521 521 522 - $lock_clause = ''; 523 - if ($connection->isReadLocking()) { 524 - $lock_clause = 'FOR UPDATE'; 525 - } else if ($connection->isWriteLocking()) { 526 - $lock_clause = 'LOCK IN SHARE MODE'; 522 + if ($conn->isReadLocking()) { 523 + $lock_clause = qsprintf($conn, 'FOR UPDATE'); 524 + } else if ($conn->isWriteLocking()) { 525 + $lock_clause = qsprintf($conn, 'LOCK IN SHARE MODE'); 526 + } else { 527 + $lock_clause = qsprintf($conn, ''); 527 528 } 528 529 529 530 $args = func_get_args(); ··· 534 535 array_push($args, $lock_clause); 535 536 array_unshift($args, $pattern); 536 537 537 - return call_user_func_array( 538 - array($connection, 'queryData'), 539 - $args); 538 + return call_user_func_array(array($conn, 'queryData'), $args); 540 539 } 541 540 542 541