From 99bcf06c62e82faf80dde2eed3f4eb21f21663c6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 11 Nov 2014 18:47:22 -0800 Subject: [PATCH] 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 --- .../phriction/query/PhrictionDocumentQuery.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/applications/phriction/query/PhrictionDocumentQuery.php b/src/applications/phriction/query/PhrictionDocumentQuery.php index f47745d191..b4e5cbbaeb 100644 --- a/src/applications/phriction/query/PhrictionDocumentQuery.php +++ b/src/applications/phriction/query/PhrictionDocumentQuery.php @@ -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,