@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Provide more buildXClause() and buildXClauseParts() on PolicyAwareQuery

Summary:
Ref T4100. Ref T5595. These functions are trivial for now, but move us toward being able to define more default query behavior by default.

Future changes will give these methods meaningful, nontrivial behaviors.

Test Plan: `arc unit --everything`

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5595, T4100

Differential Revision: https://secure.phabricator.com/D12454

+194 -16
+1 -1
src/applications/almanac/query/AlmanacServiceQuery.php
··· 75 75 return $table->loadAllFromArray($data); 76 76 } 77 77 78 - protected function buildJoinClause($conn_r) { 78 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 79 79 $joins = array(); 80 80 81 81 if ($this->devicePHIDs !== null) {
+1 -1
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 129 129 } 130 130 } 131 131 132 - private function buildJoinClause($conn_r) { 132 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 133 133 $joins = array(); 134 134 135 135 if ($this->participantPHIDs !== null) {
+1 -1
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 511 511 } 512 512 } 513 513 514 - private function buildJoinClause($conn_r) { 514 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 515 515 $joins = array(); 516 516 $audit_request = new PhabricatorRepositoryAuditRequest(); 517 517
+1 -1
src/applications/feed/query/PhabricatorFeedQuery.php
··· 37 37 return PhabricatorFeedStory::loadAllFromRows($data, $this->getViewer()); 38 38 } 39 39 40 - private function buildJoinClause(AphrontDatabaseConnection $conn_r) { 40 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 41 41 // NOTE: We perform this join unconditionally (even if we have no filter 42 42 // PHIDs) to omit rows which have no story references. These story data 43 43 // rows are notifications or realtime alerts.
+1 -1
src/applications/files/query/PhabricatorFileQuery.php
··· 215 215 return $files; 216 216 } 217 217 218 - private function buildJoinClause(AphrontDatabaseConnection $conn_r) { 218 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 219 219 $joins = array(); 220 220 221 221 if ($this->transforms) {
+1 -1
src/applications/legalpad/query/LegalpadDocumentQuery.php
··· 134 134 return $documents; 135 135 } 136 136 137 - private function buildJoinClause($conn_r) { 137 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 138 138 $joins = array(); 139 139 140 140 if ($this->contributorPHIDs !== null) {
+1 -1
src/applications/owners/query/PhabricatorOwnersPackageQuery.php
··· 35 35 return $table->loadAllFromArray($data); 36 36 } 37 37 38 - private function buildJoinClause(AphrontDatabaseConnection $conn_r) { 38 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 39 39 $joins = array(); 40 40 41 41 if ($this->ownerPHIDs) {
+1 -1
src/applications/phortune/query/PhortuneAccountQuery.php
··· 102 102 return $this->formatWhereClause($where); 103 103 } 104 104 105 - private function buildJoinClause(AphrontDatabaseConnection $conn) { 105 + protected function buildJoinClause(AphrontDatabaseConnection $conn) { 106 106 $joins = array(); 107 107 108 108 if ($this->memberPHIDs) {
+1 -1
src/applications/phortune/query/PhortuneMerchantQuery.php
··· 82 82 return $this->formatWhereClause($where); 83 83 } 84 84 85 - private function buildJoinClause(AphrontDatabaseConnection $conn) { 85 + protected function buildJoinClause(AphrontDatabaseConnection $conn) { 86 86 $joins = array(); 87 87 88 88 if ($this->memberPHIDs !== null) {
+1 -1
src/applications/phriction/query/PhrictionDocumentQuery.php
··· 190 190 return $documents; 191 191 } 192 192 193 - private function buildJoinClause(AphrontDatabaseConnection $conn) { 193 + protected function buildJoinClause(AphrontDatabaseConnection $conn) { 194 194 $join = ''; 195 195 196 196 if ($this->getOrderVector()->containsKey('updated')) {
+1 -1
src/applications/project/query/PhabricatorProjectQuery.php
··· 336 336 } 337 337 } 338 338 339 - private function buildJoinClause($conn_r) { 339 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 340 340 $joins = array(); 341 341 342 342 if (!$this->needMembers !== null) {
+1 -1
src/infrastructure/daemon/workers/query/PhabricatorWorkerTriggerQuery.php
··· 145 145 return $triggers; 146 146 } 147 147 148 - private function buildJoinClause(AphrontDatabaseConnection $conn_r) { 148 + protected function buildJoinClause(AphrontDatabaseConnection $conn_r) { 149 149 $joins = array(); 150 150 151 151 if (($this->nextEpochMin !== null) ||
+108 -3
src/infrastructure/query/PhabricatorQuery.php
··· 1 1 <?php 2 2 3 + /** 4 + * @task format Formatting Query Clauses 5 + */ 3 6 abstract class PhabricatorQuery { 7 + 4 8 5 9 abstract public function execute(); 6 10 7 - final protected function formatWhereClause(array $parts) { 8 - $parts = array_filter($parts); 11 + 12 + /* -( Formatting Query Clauses )------------------------------------------- */ 13 + 14 + 15 + /** 16 + * @task format 17 + */ 18 + protected function formatWhereClause(array $parts) { 19 + $parts = $this->flattenSubclause($parts); 20 + if (!$parts) { 21 + return ''; 22 + } 23 + 24 + return 'WHERE '.$this->formatWhereSubclause($parts); 25 + } 26 + 27 + 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 + 41 + /** 42 + * @task format 43 + */ 44 + protected function formatSelectClause(array $parts) { 45 + $parts = $this->flattenSubclause($parts); 46 + if (!$parts) { 47 + throw new Exception(pht('Can not build empty select clause!')); 48 + } 49 + 50 + return 'SELECT '.$this->formatSelectSubclause($parts); 51 + } 52 + 53 + 54 + /** 55 + * @task format 56 + */ 57 + protected function formatSelectSubclause(array $parts) { 58 + $parts = $this->flattenSubclause($parts); 59 + if (!$parts) { 60 + return null; 61 + } 62 + return implode(', ', $parts); 63 + } 64 + 9 65 66 + /** 67 + * @task format 68 + */ 69 + protected function formatJoinClause(array $parts) { 70 + $parts = $this->flattenSubclause($parts); 10 71 if (!$parts) { 11 72 return ''; 12 73 } 13 74 14 - return 'WHERE ('.implode(') AND (', $parts).')'; 75 + return implode(' ', $parts); 76 + } 77 + 78 + 79 + /** 80 + * @task format 81 + */ 82 + protected function formatHavingClause(array $parts) { 83 + $parts = $this->flattenSubclause($parts); 84 + if (!$parts) { 85 + return ''; 86 + } 87 + 88 + return 'HAVING '.$this->formatHavingSubclause($parts); 89 + } 90 + 91 + 92 + /** 93 + * @task format 94 + */ 95 + protected function formatHavingSubclause(array $parts) { 96 + $parts = $this->flattenSubclause($parts); 97 + if (!$parts) { 98 + return null; 99 + } 100 + 101 + return '('.implode(') AND (', $parts).')'; 102 + } 103 + 104 + 105 + /** 106 + * @task format 107 + */ 108 + private function flattenSubclause(array $parts) { 109 + $result = array(); 110 + foreach ($parts as $part) { 111 + if (is_array($part)) { 112 + foreach ($this->flattenSubclause($part) as $subpart) { 113 + $result[] = $subpart; 114 + } 115 + } else if (strlen($part)) { 116 + $result[] = $part; 117 + } 118 + } 119 + return $result; 15 120 } 16 121 17 122 }
+74 -1
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 183 183 /** 184 184 * @task clauses 185 185 */ 186 + protected function buildSelectClause(AphrontDatabaseConnection $conn) { 187 + $parts = $this->buildSelectClauseParts($conn); 188 + return $this->formatSelectClause($parts); 189 + } 190 + 191 + 192 + /** 193 + * @task clauses 194 + */ 195 + protected function buildSelectClauseParts(AphrontDatabaseConnection $conn) { 196 + $select = array(); 197 + 198 + $alias = $this->getPrimaryTableAlias(); 199 + if ($alias) { 200 + $select[] = qsprintf($conn, '%T.*', $alias); 201 + } else { 202 + $select[] = '*'; 203 + } 204 + 205 + return $select; 206 + } 207 + 208 + 209 + /** 210 + * @task clauses 211 + */ 212 + protected function buildJoinClause(AphrontDatabaseConnection $conn) { 213 + $joins = $this->buildJoinClauseParts($conn); 214 + return $this->formatJoinClause($joins); 215 + } 216 + 217 + 218 + /** 219 + * @task clauses 220 + */ 221 + protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { 222 + $joins = array(); 223 + return $joins; 224 + } 225 + 226 + 227 + /** 228 + * @task clauses 229 + */ 186 230 protected function buildWhereClause(AphrontDatabaseConnection $conn) { 187 - throw new PhutilMethodNotImplementedException(); 231 + $where = $this->buildWhereClauseParts($conn); 232 + return $this->formatWhereClause($where); 233 + } 234 + 235 + 236 + /** 237 + * @task clauses 238 + */ 239 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 240 + $where = array(); 241 + $where[] = $this->buildPagingClause($conn); 242 + return $where; 243 + } 244 + 245 + 246 + /** 247 + * @task clauses 248 + */ 249 + protected function buildHavingClause(AphrontDatabaseConnection $conn) { 250 + $having = $this->buildHavingClauseParts($conn); 251 + return $this->formatHavingClause($having); 252 + } 253 + 254 + 255 + /** 256 + * @task clauses 257 + */ 258 + protected function buildHavingClauseParts(AphrontDatabaseConnection $conn) { 259 + $having = array(); 260 + return $having; 188 261 } 189 262 190 263