summaryrefslogtreecommitdiff
path: root/modules/comment/comment.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-10-20 21:35:35 +0000
committerDries Buytaert <dries@buytaert.net>2003-10-20 21:35:35 +0000
commit93add5ad77889ff5369cbc1e1b4e7d0573d5e7c0 (patch)
treed3c509c723cb2fa8763e880017530afac656c0c0 /modules/comment/comment.module
parentf54c384381e4b6de879a5ed90ca0e8149c9052de (diff)
downloadbrdo-93add5ad77889ff5369cbc1e1b4e7d0573d5e7c0.tar.gz
brdo-93add5ad77889ff5369cbc1e1b4e7d0573d5e7c0.tar.bz2
- Simplified comment counter caches a bit: removed some redundant SQL code.
Maybe this will fix Jeremy's "phantom comments".
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r--modules/comment/comment.module12
1 files changed, 5 insertions, 7 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 1f048fc40..e038285e2 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -1502,21 +1502,19 @@ function comment_num_all($nid) {
static $cache;
if (!isset($cache[$nid])) {
- $comment = db_fetch_object(db_query("SELECT COUNT(nid) AS number FROM {comments} WHERE nid = %d AND status = 0 GROUP BY nid", $nid));
- $cache[$nid] = $comment->number ? $comment->number : 0;
+ $cache[$nid] = db_result(db_query("SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = 0", $nid));
}
return $cache[$nid];
}
-function comment_num_replies($id) {
+function comment_num_replies($pid) {
static $cache;
- if (!isset($cache[$id])) {
- $result = db_query("SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND status = 0", $id);
- $cache[$id] = $result ? db_result($result, 0) : 0;
+ if (!isset($cache[$pid])) {
+ $cache[$pid] = db_result(db_query("SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND status = 0", $pid));
}
- return $cache[$id];
+ return $cache[$pid];
}
/**