Hi,
Hi,

I tried using the 1.1 and the latest drupal 5 dev version, but the user warning remains.
What I have seen on drupal is this occurs because Drupal doesn't populate every row in the node_comment_statistics table, just the rows for nodes that have comments. This caused a problem with a join that caused a module to try to reinsert existing rows.

My user-warning is the following:

user warning: Duplicate entry '11044' for key 1 query: INSERT INTO node_comment_statistics (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (11044, 1215943146, NULL, 1, 0) in /httpdocs/includes/database.mysql.inc on line 172.

I also tried altering the sequences table (making the NID higher than the NID in the node_comment_statistics table), but that didn't work also.
By disabling this module, the error was gone, so I asume the node_comment module is the problem here unfortunately.

Thanks a lot for going into this!

Greetings,
Martijn

Comments

summit’s picture

Still this error, anyone has a cure?

This goes wrong by inserting a new node I think line 428-229 nodecomment.module:

      // otherwise, update it's comment statistics.
      else {
        db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, %d)', $node->nid, $node->created, $node->uid, 0);
      }

Error I got is:

Duplicate entry '1814' for key 1 query: INSERT INTO node_comment_statistics (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (1814, 1218792003, NULL, 7, 0) in /public_html/includes/database.mysql.inc on line 172.

I got this for every node I insert, without inserting a comment.

For now I just // these lines..

      //else {
       // db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, %d)', $node->nid, $node->created, $node->uid, 0);
      //}

The error is gone. Does this has wrong effects on the code?

I think in the ELSE also there has to be checked "When the node has NO comments...
How can I do that please?

EDIT:

else {
        //db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, %d)', $node->nid, $node->created, $node->uid, 0);
        db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = %d, last_comment_uid = %d WHERE nid = %d", 0, NULL, 0, 0, $nid); 
      }

should this work?

greetings,
Martijn

summit’s picture

Version: 5.x-1.x-dev » 5.x-1.1

Anyone please?
How can I get nodecomment to work correctly without getting the duplicate warning?

Thanks a lot in advance for your reply!

greetings,
Martijn

Utternonsense’s picture

Martijn,

I also just discovered this problem today - does commenting out that line disable the module at at all or does it still seem to work?

Looking forward to a fix...

crea’s picture

Status: Active » Closed (fixed)

D5 branch is not supported anymore. Closing.
Please reopen if the issue is relevant with Nodecomment 6.x-2 branch.