comment_post_ID 0 (cannot remove from dashboard)

by Zach   Last Updated March 08, 2019 11:08 AM

Ran across something a bit odd that I haven't seen before. A client has a pretty active blog and uses Akismet (paid) to protect against spam. At least once a day, they're reporting a spam comment that is correctly marked as spam, but cannot be removed from the admin dashboard by clicking Empty Spam or manually selecting the entry and trying to delete it.

I looked into this and noticed that the DB entry has a comment_post_ID of 0, which I'd have to assume means it is not attached to any post. I can obviously remove them manual from the DB (and it works just fine), but haven't found any information on what this could be.

I've replaced the core WP files (thinking it might be a security issue) and also re-generated the salts/keys in the wp-config.php file without any change.

Any thoughts would be a huge help. thanks!


While this may have stemmed from, I'm not sure if it is the result of the InMotion hack.

Here's what's been done:

  • Changed FTP, MySQL passwords
  • Created new DB user, assigned to database
  • Updated salts/keys in wp-config.php
  • Changed all WP user passwords
  • Re-installed core WordPress files

Akismet is out of ideas on this one (don't blame them) as this one is persistent.

Answers 1

I'm sorry can't comment here but i'll try to help.

wp_handle_comment_submission function handing comments posting contains exact check for post_id:

    $post = get_post( $comment_post_ID );

    if ( empty( $post->comment_status ) ) {
       return error_happened; 

i.e. (1) it passes through , or (2) comment was added other than default way of posting comments.

For (1) - check that post with id=0 doesnt exists in db, wp_posts table. Sometimes failures in database cause presence of such records
March 08, 2019 10:17 AM

Related Questions

Updated March 07, 2018 06:08 AM

Updated May 02, 2015 22:03 PM

Updated May 14, 2018 15:08 PM

Updated July 20, 2015 13:03 PM

Updated April 26, 2017 11:08 AM