Commit 86af977e authored by Steven Wittens's avatar Steven Wittens

- #15500: Fix tracker not showing nodes without comments.

- Tiny code style fix
parent e7edb55d
...@@ -1862,7 +1862,7 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) { ...@@ -1862,7 +1862,7 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
* The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed. * The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed.
*/ */
function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) { function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
list($join, $where,$nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args); list($join, $where, $nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args);
$query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query); $query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
......
...@@ -1862,7 +1862,7 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) { ...@@ -1862,7 +1862,7 @@ function _node_rewrite_sql($query = '', $nid_alias = 'n', $args = array()) {
* The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed. * The original query with JOIN and WHERE statements inserted from hook_node_rewrite_sql implementations. nid is rewritten if needed.
*/ */
function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) { function node_rewrite_sql($query, $nid_alias = 'n', $args = array()) {
list($join, $where,$nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args); list($join, $where, $nid_to_select) = _node_rewrite_sql($query, $nid_alias, $args);
$query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query); $query = preg_replace('/(SELECT.*)('. $nid_alias .'\.)?nid(.*FROM)/AUs', '\1'. $nid_to_select .'\3', $query);
......
...@@ -73,9 +73,9 @@ function tracker_page($uid = 0) { ...@@ -73,9 +73,9 @@ function tracker_page($uid = 0) {
$output .= ''; $output .= '';
if ($uid) { if ($uid) {
$sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC'; $sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC';
$sql = node_rewrite_sql($sql); $sql = node_rewrite_sql($sql);
$sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)'; $sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
$sql_count = node_rewrite_sql($sql_count); $sql_count = node_rewrite_sql($sql_count);
$result = pager_query($sql, 25, 0, $sql_count, $uid, $uid); $result = pager_query($sql, 25, 0, $sql_count, $uid, $uid);
} }
......
...@@ -73,9 +73,9 @@ function tracker_page($uid = 0) { ...@@ -73,9 +73,9 @@ function tracker_page($uid = 0) {
$output .= ''; $output .= '';
if ($uid) { if ($uid) {
$sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC'; $sql = 'SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.last_comment_timestamp AS last_post, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_post DESC';
$sql = node_rewrite_sql($sql); $sql = node_rewrite_sql($sql);
$sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND c.status = 0 WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)'; $sql_count = 'SELECT n.nid FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = 0 OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
$sql_count = node_rewrite_sql($sql_count); $sql_count = node_rewrite_sql($sql_count);
$result = pager_query($sql, 25, 0, $sql_count, $uid, $uid); $result = pager_query($sql, 25, 0, $sql_count, $uid, $uid);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment