Whenever a user attempts to save a comment, it generates 2 errors in my error log (Comment and php) and the comment is not saved. I've searched google and here and find similar problems with Feeds and images but not comments and I'm not sure how to fix it.

Here's the error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'comment-202-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_comment_body} (entity_type, entity_id, revision_id, bundle, delta, language, comment_body_value, comment_body_format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => comment [:db_insert_placeholder_1] => 202 [:db_insert_placeholder_2] => 202 [:db_insert_placeholder_3] => comment_node_article [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => test comment [:db_insert_placeholder_7] => filtered_html ) in field_sql_storage_field_storage_write() (line 514 of /home/uvumfcom/public_html/jonhainphotography.com/modules/field/modules/field_sql_storage/field_sql_storage.module).

Any help is appreciated.

Comments

John_B’s picture

Looks a bit tricky. The same question was asked here, and received little in the way of useful response. However, I would take a look at field_data_comment_body in phpmyadmin or a similar tool and see whether you can see a row in that database table where the entity_id is 202, and perhaps experimenting with deleting it if you can, try posting the comment again, and see what happens.

[Health warning: it is always safest to back up a database before manually editing it, especially if the site is live.]

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

SlimGrin’s picture

I tried your suggestion. I did find entity_id 202 and deleted it.

When I attempted to save the comment again I got the same error except at 203 so I deleted that row plus a bunch more -- they were all old spammer comments.

I tried again and got the same error except for entity_id 204 which I had just deleted... I'm confused about that but also wondering why it is counting comments in the 200s when there are about 300 already in the db.

John_B’s picture

OK. I am fairly lost at the momement with this, and of course it is harder trying to help with diagnosis than doing it hands-on (which I don't do unpaid). A good next step, though a possibly laborious one, would be to disable all the contributed and custom modules on the site, and see whether it works then. It is possible a module is trying to save the comment twice and that is causing a problem.

In addition, if there are spammer comments it shows comments were working in the past so you could try to work out when the problem arose.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors