1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Fix minor issues with PhrictionDocumentQuery

Summary:

  - Order checks used `=` but intended `==`. We could probably write a lint rule for this.
  - Selecting `*` with a join could pick (for example) `id` columns from both the document and content tables and end up using the wrong one.
  - `%Q` expects a string and chokes on `null`.

Auditors: btrahan
This commit is contained in:
epriestley 2014-11-11 18:47:22 -08:00
parent 8e1a4eef04
commit 99bcf06c62

View file

@ -10,7 +10,6 @@ final class PhrictionDocumentQuery
private $slugPrefix;
private $statuses;
private $needContent;
private $status = 'status-any';
@ -72,7 +71,7 @@ final class PhrictionDocumentQuery
$table = new PhrictionDocument();
$conn_r = $table->establishConnection('r');
if ($this->order = self::ORDER_HIERARCHY) {
if ($this->order == self::ORDER_HIERARCHY) {
$order_clause = $this->buildHierarchicalOrderClause($conn_r);
} else {
$order_clause = $this->buildOrderClause($conn_r);
@ -80,7 +79,7 @@ final class PhrictionDocumentQuery
$rows = queryfx_all(
$conn_r,
'SELECT * FROM %T d %Q %Q %Q %Q',
'SELECT d.* FROM %T d %Q %Q %Q %Q',
$table->getTableName(),
$this->buildJoinClause($conn_r),
$this->buildWhereClause($conn_r),
@ -186,8 +185,8 @@ final class PhrictionDocumentQuery
}
private function buildJoinClause(AphrontDatabaseConnection $conn) {
$join = null;
if ($this->order = self::ORDER_HIERARCHY) {
$join = '';
if ($this->order == self::ORDER_HIERARCHY) {
$content_dao = new PhrictionContent();
$join = qsprintf(
$conn,