Fixing pending comments issue

WordPress comments are very reliable and it is very rare that you’ll ever see this issue on your site. But just like with all technology, things sometimes fail and then you need to debug and correct them. I searched internet and found nothing. Hopefully, some of you will find this post useful.

So, one day all of a sudden I find that I have 24 pending comments in my WordPress admin dashboard comments panel and when I click on pending comments link it shows no comments.

I realised that people were commenting but getting the error.

 


comments not saved

So, first I tried to optimise database which did not work. Then I started debugging code, the error message appears from wp-includes/comments.php which runs the function wp_new_comment which runs the function wp_insert_comment  which runs $wpdb->insert in wp-includes/wp-db.php which runs the function _insert_replace_helper and in this function I got the generated sql file. I printed the sql query [ print_r($this->prepare( $sql, $values ) ) ] and ran the query directly in the database. Then I found that the query was running but the comment_ID was generated as 0.

So, it was a database issue, when I edited the structure of the wp_comments table, I found that comment_ID was neither set as primary key, not it was set on auto increment mode.

The fix was to remove all the comments with comment_ID as 0 and then setting the comment_ID as primary key and auto-increment.

Finally comments were back on my site.

November 28, 2018

0 responses on "Fixing pending comments issue"

Leave a Reply

top
Template Design © VibeThemes. All rights reserved.

Privacy Preference Center

Necessary

This cookie is set when you login to your account at VibeThemes. VibeThemes based on WordPress sets this cookie, which indicates when you're logged in, and who you are, for most interface use.

WordPress uses the two cookies to bypass the password entry portion of wp-login.php. If WordPress recognizes that you have valid, non-expired cookies, you go directly to the WordPress Administration interface. If you don't have the cookies, or they're expired, or in some other way invalid (like you edited them manually for some reason), WordPress will require you to log in again, in order to obtain new cookies.

wordpress_logged_in_[hash],wp-settings-{time}-[UID]

Advertising

Analytics

Comments

When you comment on VibeThemes blog, they too get cookies stored on their computer. This is purely a convenience, so that the visitor won't need to re-type all their information again when they want to leave another comment.
The commenter cookies are set to expire a little under one year from the time they're set.

comment_author_{HASH},comment_author_email_{HASH},comment_author_url_{HASH},

%d bloggers like this: