@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.

Continue cleaning up queries in the wake of changes to "%Q"

Summary: Depends on D19810. Ref T13217. Ref T13216. I mostly used `grep implode | grep OR` and `grep implode | grep AND` to find these -- not totally exhaustive but should be a big chunk of the callsites that are missing `%LO` / `%LA`.

Test Plan:
These are tricky to test exhaustively, but I made an attempt to hit most of them:

- Browsed Almanac interfaces.
- Created/browsed Calendar events.
- Enabled/disabled/showed the lock log.
- Browsed repositories.
- Loaded Facts UI.
- Poked at Multimeter.
- Used typeahead for users and projects.
- Browsed Phriction.
- Ran various fulltext searches.

Not sure these are reachable:

- All the lint stuff might be dead/unreachable/nonfunctional?

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: yelirekim

Maniphest Tasks: T13217, T13216

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

+59 -44
+1 -1
src/applications/almanac/query/AlmanacInterfaceQuery.php
··· 121 121 $address->getAddress(), 122 122 $address->getPort()); 123 123 } 124 - $where[] = implode(' OR ', $parts); 124 + $where[] = qsprintf($conn, '%LO', $parts); 125 125 } 126 126 127 127 return $where;
+2 -2
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
··· 444 444 445 445 $where[] = qsprintf( 446 446 $conn, 447 - '%Q', 448 - implode(' OR ', $sql)); 447 + '%LO', 448 + $sql); 449 449 } 450 450 451 451 if ($this->isStub !== null) {
+2 -2
src/applications/daemon/management/PhabricatorLockLogManagementWorkflow.php
··· 107 107 } 108 108 109 109 if (!$parts) { 110 - $constraint = '1 = 1'; 110 + $constraint = qsprintf($conn, '1 = 1'); 111 111 } else { 112 - $constraint = '('.implode(') AND (', $parts).')'; 112 + $constraint = qsprintf($conn, '%LA', $parts); 113 113 } 114 114 115 115 $logs = $table->loadAllWhere(
+4 -4
src/applications/diffusion/DiffusionLintSaveRunner.php
··· 229 229 $this->conn, 230 230 'INSERT INTO %T 231 231 (branchID, path, line, code, severity, name, description) 232 - VALUES %Q', 232 + VALUES %LQ', 233 233 PhabricatorRepository::TABLE_LINTMESSAGE, 234 - implode(', ', $values)); 234 + $values); 235 235 } 236 236 237 237 $this->conn->saveTransaction(); ··· 295 295 } 296 296 queryfx( 297 297 $this->conn, 298 - 'UPDATE %T SET authorPHID = %s WHERE %Q', 298 + 'UPDATE %T SET authorPHID = %s WHERE %LO', 299 299 PhabricatorRepository::TABLE_LINTMESSAGE, 300 300 $author, 301 - implode(' OR ', $where)); 301 + $where); 302 302 } 303 303 304 304 $this->conn->saveTransaction();
+2 -2
src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
··· 451 451 WHERE repositoryID = %d 452 452 AND parentID = %d 453 453 AND existed = 1 454 - AND (%Q) 454 + AND (%LO) 455 455 ORDER BY pathName', 456 456 PhabricatorRepository::TABLE_FILESYSTEM, 457 457 PhabricatorRepository::TABLE_PATH, 458 458 $repository->getID(), 459 459 $path_id, 460 - implode(' OR ', $sql)); 460 + $sql); 461 461 462 462 $loadable_commits = array(); 463 463 foreach ($browse as $key => $file) {
+6 -6
src/applications/diffusion/controller/DiffusionLintController.php
··· 276 276 array_keys($branch), 277 277 $path->getPath()); 278 278 if ($path->getExcluded()) { 279 - $where[] = 'NOT '.$condition; 279 + $where[] = qsprintf($conn, 'NOT %Q', $condition); 280 280 } else { 281 281 $or[] = $condition; 282 282 } 283 283 } 284 284 } 285 - $where[] = '('.implode(' OR ', $or).')'; 285 + $where[] = qsprintf($conn, '%LO', $or); 286 286 } 287 287 288 288 return queryfx_all( ··· 296 296 COUNT(DISTINCT path) AS files, 297 297 COUNT(*) AS n 298 298 FROM %T 299 - WHERE %Q 299 + WHERE %LA 300 300 GROUP BY branchID, code 301 301 ORDER BY n DESC', 302 302 PhabricatorRepository::TABLE_LINTMESSAGE, 303 - implode(' AND ', $where)); 303 + $where); 304 304 } 305 305 306 306 protected function buildActionView(DiffusionRequest $drequest) { ··· 526 526 $conn, 527 527 'SELECT * 528 528 FROM %T 529 - WHERE %Q 529 + WHERE %LA 530 530 ORDER BY path, code, line LIMIT %d OFFSET %d', 531 531 PhabricatorRepository::TABLE_LINTMESSAGE, 532 - implode(' AND ', $where), 532 + $where, 533 533 $limit, 534 534 $offset); 535 535 }
+2 -2
src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php
··· 81 81 $commits = queryfx_all( 82 82 $conn_r, 83 83 'SELECT commitIdentifier FROM %T 84 - WHERE repositoryID = %s AND %Q', 84 + WHERE repositoryID = %s AND %LO', 85 85 id(new PhabricatorRepositoryCommit())->getTableName(), 86 86 $repository->getID(), 87 - implode(' OR ', $prefixes)); 87 + $prefixes); 88 88 89 89 foreach ($commits as $commit) { 90 90 $hash = $commit['commitIdentifier'];
+2 -2
src/applications/fact/query/PhabricatorFactDatapointQuery.php
··· 158 158 $this->dimensionMap); 159 159 } 160 160 161 - $where = '('.implode(') AND (', $where).')'; 161 + $where = qsprintf($conn, '%LA', $where); 162 162 163 163 if ($this->limit) { 164 164 $limit = qsprintf( ··· 166 166 'LIMIT %d', 167 167 $this->limit); 168 168 } else { 169 - $limit = ''; 169 + $limit = qsprintf($conn, ''); 170 170 } 171 171 172 172 return queryfx_all(
+3 -5
src/applications/multimeter/controller/MultimeterSampleController.php
··· 52 52 } 53 53 } 54 54 55 - $where = '('.implode(') AND (', $where).')'; 56 - 57 55 $data = queryfx_all( 58 56 $conn, 59 57 'SELECT *, ··· 61 59 SUM(sampleRate * resourceCost) AS totalCost, 62 60 SUM(sampleRate * resourceCost) / SUM(sampleRate) AS averageCost 63 61 FROM %T 64 - WHERE %Q 65 - GROUP BY %Q 62 + WHERE %LA 63 + GROUP BY %LC 66 64 ORDER BY totalCost DESC, MAX(id) DESC 67 65 LIMIT 100', 68 66 $table->getTableName(), 69 67 $where, 70 - implode(', ', array_select_keys($group_map, $group))); 68 + array_select_keys($group_map, $group)); 71 69 72 70 $this->loadDimensions($data); 73 71 $phids = array();
+1 -1
src/applications/packages/query/PhabricatorPackagesQuery.php
··· 32 32 throw new PhabricatorEmptyQueryException(); 33 33 } 34 34 35 - return implode(' OR ', $parts); 35 + return qsprintf($conn, '%LO', $parts); 36 36 } 37 37 38 38 }
+1 -1
src/applications/people/query/PhabricatorPeopleQuery.php
··· 268 268 'user.username LIKE %>', 269 269 $name_prefix); 270 270 } 271 - $where[] = '('.implode(' OR ', $parts).')'; 271 + $where[] = qsprintf($conn, '%LO', $parts); 272 272 } 273 273 274 274 if ($this->emails !== null) {
+2 -2
src/applications/phrequent/query/PhrequentUserTimeQuery.php
··· 177 177 178 178 $preempting_events = queryfx_all( 179 179 $conn_r, 180 - 'SELECT * FROM %T WHERE %Q ORDER BY dateStarted ASC, id ASC', 180 + 'SELECT * FROM %T WHERE %LO ORDER BY dateStarted ASC, id ASC', 181 181 $usertime->getTableName(), 182 - implode(' OR ', $preempt)); 182 + $preempt); 183 183 $preempting_events = $usertime->loadAllFromArray($preempting_events); 184 184 185 185 $preempting_events = mgroup($preempting_events, 'getUserPHID');
+6 -2
src/applications/phriction/query/PhrictionDocumentQuery.php
··· 309 309 $max); 310 310 } 311 311 312 - $path_clauses[] = '('.implode(') AND (', $parts).')'; 312 + if ($parts) { 313 + $path_clauses[] = qsprintf($conn, '%LA', $parts); 314 + } 313 315 } 314 316 315 - $where[] = '('.implode(') OR (', $path_clauses).')'; 317 + if ($path_clauses) { 318 + $where[] = qsprintf($conn, '%LO', $path_clauses); 319 + } 316 320 } 317 321 318 322 return $where;
+1 -1
src/applications/project/query/PhabricatorProjectQuery.php
··· 514 514 'name LIKE %>', 515 515 $name_prefix); 516 516 } 517 - $where[] = '('.implode(' OR ', $parts).')'; 517 + $where[] = qsprintf($conn, '%LO', $parts); 518 518 } 519 519 520 520 if ($this->icons !== null) {
+24 -11
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
··· 1440 1440 $key); 1441 1441 } 1442 1442 1443 - return implode(' ', $joins); 1443 + if ($joins) { 1444 + return qsprintf($conn, '%LJ', $joins); 1445 + } else { 1446 + return qsprintf($conn, ''); 1447 + } 1444 1448 } 1445 1449 1446 1450 /** ··· 1516 1520 } 1517 1521 1518 1522 if ($constraint_parts) { 1519 - $where[] = '('.implode(') OR (', $constraint_parts).')'; 1523 + $where[] = qsprintf($conn, '%LO', $constraint_parts); 1520 1524 } 1521 1525 break; 1522 1526 } ··· 1670 1674 } 1671 1675 1672 1676 if (!$this->ferretEngine) { 1673 - $select[] = '0 _ft_rank'; 1677 + $select[] = qsprintf($conn, '0 _ft_rank'); 1674 1678 return $select; 1675 1679 } 1676 1680 ··· 1736 1740 } 1737 1741 } 1738 1742 1739 - $parts[] = '0'; 1743 + $parts[] = qsprintf($conn, '%d', 0); 1744 + 1745 + $sum = array_shift($parts); 1746 + foreach ($parts as $part) { 1747 + $sum = qsprintf( 1748 + $conn, 1749 + '%Q + %Q', 1750 + $sum, 1751 + $part); 1752 + } 1740 1753 1741 1754 $select[] = qsprintf( 1742 1755 $conn, 1743 1756 '%Q _ft_rank', 1744 - implode(' + ', $parts)); 1757 + $sum); 1745 1758 1746 1759 return $select; 1747 1760 } ··· 2031 2044 if ($is_not) { 2032 2045 $where[] = qsprintf( 2033 2046 $conn, 2034 - '(%Q)', 2035 - implode(' AND ', $term_constraints)); 2047 + '%LA', 2048 + $term_constraints); 2036 2049 } else if ($is_quoted) { 2037 2050 $where[] = qsprintf( 2038 2051 $conn, 2039 - '(%T.rawCorpus LIKE %~ AND (%Q))', 2052 + '(%T.rawCorpus LIKE %~ AND %LO)', 2040 2053 $table_alias, 2041 2054 $value, 2042 - implode(' OR ', $term_constraints)); 2055 + $term_constraints); 2043 2056 } else { 2044 2057 $where[] = qsprintf( 2045 2058 $conn, 2046 - '(%Q)', 2047 - implode(' OR ', $term_constraints)); 2059 + '%LO', 2060 + $term_constraints); 2048 2061 } 2049 2062 } 2050 2063