Closed (fixed)
Project:
Node Comments
Version:
6.x-1.2-rc2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Apr 2009 at 00:00 UTC
Updated:
10 Jun 2009 at 21:40 UTC
hello,
i'm using node comment count in views and that's what helped me realize a problem that's happening
with nodecomment module. basically when you create a node and it's in moderation (modr8 module) and
comment on it before it's approved, the node_comment_statistics table does NOT get updated - the
comment_count stays at 0 rather than 1. if you approve the parent node and -then- comment on it, the
comment_count increments to 1. but if you add a comment -before- approving the parent node (this is
possible to do as soon as the parent node is created, even if it isn't yet approved with modr8 module) it
never gets incremented to 1 and remains 0.
thanks,
bill
Comments
Comment #1
j4h8 commentedHi,
I think this is related to a bug i found in the SQL statements in nodecomment.module, function _nodecomment_update_node_statistics:
The description of the function says:
"comment_count: the total number of ***approved/published comments*** on this node."
But the SQL select the total number of comments on ***approved/published nodes***:
-> db_query('SELECT COUNT(*) FROM {node_comments} nc INNER JOIN {node} n ON n.nid = nc.nid WHERE nc.nid = %d AND n.status = %d', $nid, 1);
-> 'SELECT nc.cid, nc.name, n.created, n.changed, n.uid FROM {node} n LEFT JOIN {node_comments} nc on n.nid = nc.cid WHERE nc.nid = %d AND n.status = 1 ORDER BY cid DESC'
See the "n.status" instead of "nc.status" in both cases?
This is why the comment_count does not increment in above's scenario.
And my problem is the other way round: I want to have a count of published comments for my node, but I get the count of *all* comments for my node.
Comment #2
j4h8 commentedSorry all, please ignore my last comment, that was rubbish. I misread the SQL.
Comment #3
j4h8 commentedNext try :-)
My solution in #1 was wrong, but the idea was right.
Let me explain:
I posted an unpublished comment (cid 216) to node 132:
Now I select the countable rows to my commented node (nid 132) using the statement from nodeforum.module:
The SELECT collects *all* comments to a node that has status=1.
If you want (I do that) all *published* comments to a node, you have to select all *published comment-nodes* to the parent node:
This works for me.
Regards,
Jutta
Comment #4
quicksketchThis has been fixed in #462688: Handling of comment updates. The problem had been that comment counts were only being updated on INSERT, not on UPDATE. So when moving a node comment out of moderation, the comment counts weren't updated until another comment was posted.