Bad Comment Karma

commentkarmaBefore making the domain move the other day, I made a mistake by deleting something I shouldn’t have from the database. It was the comment_karma field located within the wp_comments table. A long time ago, I remember installing a plugin called Comment Karma which enabled visitors to rate a comment up or down thus promoting the best user rated comments to the top.

I thought that by installing this plugin a long time ago, that it had created this entry in my database. Thinking another plugin left its stuff behind in my database, I removed it only to find out that removing it broke my commenting system to the point where the incrementer broke. To make matters worst, I didn’t do a database backup since I thought I was removing something plugin related. However, thanks to Michael Torbert, he helped me put the comment_karma field back in its location and once I did that, everything worked again.

So, when I dived into the WordPress-Dev IRC channel to see what this field is used for, someone said it was not used by anything in core and Michael told me he couldn’t find anywhere that field was being used. But, if it was not being used in core, why would it cause the commenting system to break when it’s removed?

The overall lesson here, don’t do ANYTHING to your database unless you backup first. Complacency is your enemy.


6 responses to “Bad Comment Karma”

  1. I had something similar happen with another plugins left over database entry. I removed the entry in mention because I had not used the plugin for about six months and my entire blog would not load up the dashboard. Luckily I had a database backup from the day before to fix the problem.

    It was some stats plugin around the time of WP 2.5.

  2. But, if it was not being used in core, why would it cause the commenting system to break when it’s removed?

    I think you can construct Insert (or Update?) database query without specifying columns, so maybe the system was confused by (too high) number of sent values…

  3. Hi Jeffro,

    I’m pretty sure this field has nothing to do with the plugin. I have it in my DB and I’ve never installed the plugin.

    The field is used in the core code: on line 894 (in 2.8) of wp-includes/comment.php which is called when comments are inserted into the database and also on line 1115 when comments are updated.

    If the field isn’t in the DB, then WordPress will fall over when a new comment is made or an old one is edited.

    I would guess this is a field they added sometime back with the idea of one day creating a feature which used this (much like the comment_parent field was added many many versions before WordPress added threaded comment support to the core).

  4. There’s actually a database ER diagram on the Codex that you can reference if you’re ever not sure if a table/column is part of the core.

    This can save you some hassle, and it’s also an interesting way to see how all the tables connect in the backend.

    Here’s the codex page that has the 2.7 database diagram (as far as I know there aren’t any major differences between the 2.7 and 2.8 DB).

  5. Thanks all for the help. It’s not that I didn’t know it was part of core or that the thought crossed my mind. The only thought on my mind was that I had installed comment karma at some point and that field was left over from the plugin which was not the case because the table that plugin creates is different.

    So, I deleted something of core I thought was plugin related, that’s all. And thanks to Stephen, I know why it screwed up the comment system.


Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.