Have received the following warning after deleting comment:

user warning: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM node WHERE node_comment_statistics.nid = node.nid AND node query: UPDATE node_comment_statistics SET comment_count = 0, last_comment_timestamp = created, last_comment_name = '', last_comment_uid = uid FROM node WHERE node_comment_statistics.nid = node.nid AND node.nid = 47 in C:\htdocs\drupal-4.7\includes\database.mysql.inc on line 129.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tomsys’s picture

related node/46227

T.

tomsys’s picture

FileSize
1.36 KB
--- comment.module	2006-01-31 17:46:57.000000000 -0500
+++ comment.module.orig	2006-01-31 12:15:05.000000000 -0500
@@ -1685,8 +1685,6 @@
  * - comment_count: the total number of approved/published comments on this node.
  */
 function _comment_update_node_statistics($nid) {
-  global $user;
-
   $count = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = %d', $nid, COMMENT_PUBLISHED));
 
   // comments exist
@@ -1694,9 +1692,10 @@
     $last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY cid DESC', $nid, COMMENT_PUBLISHED, 0, 1));
     db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid);
   }
+
   // no comments
   else {
-    db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = %d, last_comment_name = NULL, last_comment_uid = %d WHERE nid = %d ", time(), $user->uid, $nid);
+    db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = created, last_comment_name = '', last_comment_uid = uid FROM {node} WHERE {node_comment_statistics}.nid = {node}.nid AND {node}.nid = %d", $nid);
   }
 }
tomsys’s picture

FileSize
1.36 KB

..Sorry .. the previous was Inverse Diff :(

this is the right one !!
T.

Gerhard Killesreiter’s picture

Status: Active » Needs review

Changing status.

Cvbge’s picture

Version: 4.7.0-beta4 » x.y.z
Component: node system » comment.module
Assigned: doq »
FileSize
1.01 KB

It seems I've broken this in http://drupal.org/node/44101

Please test attached patch.

Dries’s picture

Status: Needs review » Fixed

Committed to HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)