1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 23:40:57 +01:00

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
This commit is contained in:
epriestley 2018-11-15 05:53:34 -08:00
parent 49483bdb48
commit 933462b487
15 changed files with 59 additions and 44 deletions

View file

@ -121,7 +121,7 @@ final class AlmanacInterfaceQuery
$address->getAddress(),
$address->getPort());
}
$where[] = implode(' OR ', $parts);
$where[] = qsprintf($conn, '%LO', $parts);
}
return $where;

View file

@ -444,8 +444,8 @@ final class PhabricatorCalendarEventQuery
$where[] = qsprintf(
$conn,
'%Q',
implode(' OR ', $sql));
'%LO',
$sql);
}
if ($this->isStub !== null) {

View file

@ -107,9 +107,9 @@ final class PhabricatorLockLogManagementWorkflow
}
if (!$parts) {
$constraint = '1 = 1';
$constraint = qsprintf($conn, '1 = 1');
} else {
$constraint = '('.implode(') AND (', $parts).')';
$constraint = qsprintf($conn, '%LA', $parts);
}
$logs = $table->loadAllWhere(

View file

@ -229,9 +229,9 @@ final class DiffusionLintSaveRunner extends Phobject {
$this->conn,
'INSERT INTO %T
(branchID, path, line, code, severity, name, description)
VALUES %Q',
VALUES %LQ',
PhabricatorRepository::TABLE_LINTMESSAGE,
implode(', ', $values));
$values);
}
$this->conn->saveTransaction();
@ -295,10 +295,10 @@ final class DiffusionLintSaveRunner extends Phobject {
}
queryfx(
$this->conn,
'UPDATE %T SET authorPHID = %s WHERE %Q',
'UPDATE %T SET authorPHID = %s WHERE %LO',
PhabricatorRepository::TABLE_LINTMESSAGE,
$author,
implode(' OR ', $where));
$where);
}
$this->conn->saveTransaction();

View file

@ -451,13 +451,13 @@ final class DiffusionBrowseQueryConduitAPIMethod
WHERE repositoryID = %d
AND parentID = %d
AND existed = 1
AND (%Q)
AND (%LO)
ORDER BY pathName',
PhabricatorRepository::TABLE_FILESYSTEM,
PhabricatorRepository::TABLE_PATH,
$repository->getID(),
$path_id,
implode(' OR ', $sql));
$sql);
$loadable_commits = array();
foreach ($browse as $key => $file) {

View file

@ -276,13 +276,13 @@ final class DiffusionLintController extends DiffusionController {
array_keys($branch),
$path->getPath());
if ($path->getExcluded()) {
$where[] = 'NOT '.$condition;
$where[] = qsprintf($conn, 'NOT %Q', $condition);
} else {
$or[] = $condition;
}
}
}
$where[] = '('.implode(' OR ', $or).')';
$where[] = qsprintf($conn, '%LO', $or);
}
return queryfx_all(
@ -296,11 +296,11 @@ final class DiffusionLintController extends DiffusionController {
COUNT(DISTINCT path) AS files,
COUNT(*) AS n
FROM %T
WHERE %Q
WHERE %LA
GROUP BY branchID, code
ORDER BY n DESC',
PhabricatorRepository::TABLE_LINTMESSAGE,
implode(' AND ', $where));
$where);
}
protected function buildActionView(DiffusionRequest $drequest) {
@ -526,10 +526,10 @@ final class DiffusionLintController extends DiffusionController {
$conn,
'SELECT *
FROM %T
WHERE %Q
WHERE %LA
ORDER BY path, code, line LIMIT %d OFFSET %d',
PhabricatorRepository::TABLE_LINTMESSAGE,
implode(' AND ', $where),
$where,
$limit,
$offset);
}

View file

@ -81,10 +81,10 @@ final class DiffusionCachedResolveRefsQuery
$commits = queryfx_all(
$conn_r,
'SELECT commitIdentifier FROM %T
WHERE repositoryID = %s AND %Q',
WHERE repositoryID = %s AND %LO',
id(new PhabricatorRepositoryCommit())->getTableName(),
$repository->getID(),
implode(' OR ', $prefixes));
$prefixes);
foreach ($commits as $commit) {
$hash = $commit['commitIdentifier'];

View file

@ -158,7 +158,7 @@ final class PhabricatorFactDatapointQuery extends Phobject {
$this->dimensionMap);
}
$where = '('.implode(') AND (', $where).')';
$where = qsprintf($conn, '%LA', $where);
if ($this->limit) {
$limit = qsprintf(
@ -166,7 +166,7 @@ final class PhabricatorFactDatapointQuery extends Phobject {
'LIMIT %d',
$this->limit);
} else {
$limit = '';
$limit = qsprintf($conn, '');
}
return queryfx_all(

View file

@ -52,8 +52,6 @@ final class MultimeterSampleController extends MultimeterController {
}
}
$where = '('.implode(') AND (', $where).')';
$data = queryfx_all(
$conn,
'SELECT *,
@ -61,13 +59,13 @@ final class MultimeterSampleController extends MultimeterController {
SUM(sampleRate * resourceCost) AS totalCost,
SUM(sampleRate * resourceCost) / SUM(sampleRate) AS averageCost
FROM %T
WHERE %Q
GROUP BY %Q
WHERE %LA
GROUP BY %LC
ORDER BY totalCost DESC, MAX(id) DESC
LIMIT 100',
$table->getTableName(),
$where,
implode(', ', array_select_keys($group_map, $group)));
array_select_keys($group_map, $group));
$this->loadDimensions($data);
$phids = array();

View file

@ -32,7 +32,7 @@ abstract class PhabricatorPackagesQuery
throw new PhabricatorEmptyQueryException();
}
return implode(' OR ', $parts);
return qsprintf($conn, '%LO', $parts);
}
}

View file

@ -268,7 +268,7 @@ final class PhabricatorPeopleQuery
'user.username LIKE %>',
$name_prefix);
}
$where[] = '('.implode(' OR ', $parts).')';
$where[] = qsprintf($conn, '%LO', $parts);
}
if ($this->emails !== null) {

View file

@ -177,9 +177,9 @@ final class PhrequentUserTimeQuery
$preempting_events = queryfx_all(
$conn_r,
'SELECT * FROM %T WHERE %Q ORDER BY dateStarted ASC, id ASC',
'SELECT * FROM %T WHERE %LO ORDER BY dateStarted ASC, id ASC',
$usertime->getTableName(),
implode(' OR ', $preempt));
$preempt);
$preempting_events = $usertime->loadAllFromArray($preempting_events);
$preempting_events = mgroup($preempting_events, 'getUserPHID');

View file

@ -309,10 +309,14 @@ final class PhrictionDocumentQuery
$max);
}
$path_clauses[] = '('.implode(') AND (', $parts).')';
if ($parts) {
$path_clauses[] = qsprintf($conn, '%LA', $parts);
}
}
$where[] = '('.implode(') OR (', $path_clauses).')';
if ($path_clauses) {
$where[] = qsprintf($conn, '%LO', $path_clauses);
}
}
return $where;

View file

@ -514,7 +514,7 @@ final class PhabricatorProjectQuery
'name LIKE %>',
$name_prefix);
}
$where[] = '('.implode(' OR ', $parts).')';
$where[] = qsprintf($conn, '%LO', $parts);
}
if ($this->icons !== null) {

View file

@ -1440,7 +1440,11 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
$key);
}
return implode(' ', $joins);
if ($joins) {
return qsprintf($conn, '%LJ', $joins);
} else {
return qsprintf($conn, '');
}
}
/**
@ -1516,7 +1520,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
if ($constraint_parts) {
$where[] = '('.implode(') OR (', $constraint_parts).')';
$where[] = qsprintf($conn, '%LO', $constraint_parts);
}
break;
}
@ -1670,7 +1674,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
if (!$this->ferretEngine) {
$select[] = '0 _ft_rank';
$select[] = qsprintf($conn, '0 _ft_rank');
return $select;
}
@ -1736,12 +1740,21 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
}
}
$parts[] = '0';
$parts[] = qsprintf($conn, '%d', 0);
$sum = array_shift($parts);
foreach ($parts as $part) {
$sum = qsprintf(
$conn,
'%Q + %Q',
$sum,
$part);
}
$select[] = qsprintf(
$conn,
'%Q _ft_rank',
implode(' + ', $parts));
$sum);
return $select;
}
@ -2031,20 +2044,20 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
if ($is_not) {
$where[] = qsprintf(
$conn,
'(%Q)',
implode(' AND ', $term_constraints));
'%LA',
$term_constraints);
} else if ($is_quoted) {
$where[] = qsprintf(
$conn,
'(%T.rawCorpus LIKE %~ AND (%Q))',
'(%T.rawCorpus LIKE %~ AND %LO)',
$table_alias,
$value,
implode(' OR ', $term_constraints));
$term_constraints);
} else {
$where[] = qsprintf(
$conn,
'(%Q)',
implode(' OR ', $term_constraints));
'%LO',
$term_constraints);
}
}