From 09bd156ba212f56cc62de85c53f14127c719522b Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Wed, 19 Jan 2005 01:46:25 +0000 Subject: - Fix tracker pager count query being wrong (it did not return a count but a set, and it counted nodes with more than 1 comment as multiple nodes). - Clean up various SQL queries: removing literally inserted data (db_escape_string is evil!), fixing single "%" which should be "%%", fixing integers being compared as strings. --- modules/forum/forum.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/forum/forum.module') diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 936283f85..d9973222e 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -437,10 +437,10 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $term = taxonomy_get_term($tid); - $sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = '%s' AND n.uid = u.uid AND n.nid = f.nid"); + $sql = node_rewrite_sql("SELECT n.nid, f.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments FROM {node} n, {node_comment_statistics} l, {users} cu, {term_node} r, {users} u, {forum} f WHERE n.status = 1 AND l.last_comment_uid = cu.uid AND n.nid = l.nid AND n.nid = r.nid AND r.tid = %d AND n.uid = u.uid AND n.nid = f.nid"); $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,'); - $sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = '%s' WHERE n.status = 1 AND n.type = 'forum'"); + $sql_count = node_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum'"); $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid); -- cgit v1.2.3