Comments Missing in WordPress Dashboard After 2.5.1 Upgrade

I just upgraded the WordPress installation for ElasticDog to version 2.5.1 and noticed that the Manage Comments page in the administrative Dashboard was not displaying any comments. I only noticed there was a problem when the interface kept telling me there were 9 comments awaiting moderation, yet it would not let me see them. Everything was displaying correctly on the publicly viewable blog pages, but no comments showed up when trying to access them via the Dashboard.

After searching for a bit and checking my sever logs, I found that the upgrade script did not add the proper index to the “comment_date_gmt” column in the comments table for my WordPress database:

Apr 25 18:22:17 php-cgi: WordPress database error Key 'comment_date_gmt' doesn't exist in table 'wp_comment' for query...

The Solution

If you don’t want to wait until the upgrade script gets fixed in a later WordPress release, you’ll have to add the missing index to the database table yourself to get things working again. I’ll demonstrate how to do that using the MySQL command line interface, however, if you’re more comfortable with using phpMyAdmin, see the steps outlined here.

Check for Proper Privileges

First of all, you must have the proper privileges on your WordPress database in order to add an index. To check that, follow these steps:

  1. Log in to MySQL with whatever account credentials you know.
    $ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 59202
    Server version: 5.0.51a Source distribution
    
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql>
  2. Specify that you want to access the “mysql” database, then ensure that you do have the privileges to add indexes.
    mysql> use mysql
    Database changed
    mysql> SELECT user, index_priv FROM user;
    +------------------+-----------------+
    | user       | index_priv |
    +------------------+-----------------+
    | root       | Y          |
    | elasticdog | N          |
    +------------------+-----------------+
    2 rows in set (0.00 sec)

As long as you see a ‘Y’ next to your username, then you should be good to go.

Add the Index to the Comments Table

Once you have access to an account that can add indexes, then follow these steps to add the missing index:

  1. Specify that you want to access your WordPress database. If you don’t know the name of your WordPress database, run show databases; to see a list of databases you have access to.
    mysql> use elasticdog_wordpress
    Database changed
  2. Add the index. The table names for WordPress are fairly standard, but if you don’t have one named “wp_comments”, run show tables; to see a list of contenders and it should be easy to figure out.
    mysql> CREATE INDEX comment_date_gmt ON wp_comments (comment_date_gmt);
    Query OK, 458 rows affected (0.14 sec)
    Records: 458  Duplicates: 0  Warnings: 0
  3. If want to verify that the index was created, run
    SHOW INDEX FROM wp_comments; to list all indexes, and then you can exit out.

If everything went as planned, all will be right in the world and your comments should be viewable through the dashboard once again!

4 Comments

  1. Posted May 4th, 2008 at 11:05pm | Permalink

    Thank you for posting this fix. I was able to implement with only a couple clicks via my phpMyAdmin.

  2. Posted May 5th, 2008 at 10:34pm | Permalink

    I thought about it a bit more after posting this and thought that I may of had problems due to restrictive permissions given to the database user that WordPress connects up to. Although that might be the case in my situation, I decided to look at the upgrade scripts themselves, and the index was missing as I had originally thought…so the advice should still be valid.

    P.S. You’re welcome Joe :-)

  3. Posted June 22nd, 2008 at 10:08pm | Permalink

    Thanks a lot fellow. Worked like a charm.

  4. Paul
    Posted July 5th, 2008 at 4:06am | Permalink

    Last week, late one night I had to add a few more blogs to my website. I used the wordpress blog creation feature offered by my hosting company. This quickly creates the basic wordpress blog but uses an old version of wordpress. After that I uploaded the sets of wordpress plugins to each account. Among them I have been recently including the WordPress Automatic Upgrade plugin. I was very pleased that WPAU worked like a charm and even preserved the WP Cache, which is something that can only be created by the ISP’s blog initialization interface because of permission restrictions on my service(I am thinking about exploiting this on the blogs that I have lost my WP Cache). I was actually expecting an error message from WPAU regarding user privileges. It was only after some time I realized the comment_date_gmt problem and that WPAU had not reported the error, maybe it is in the log but I didn’t go looking for trouble. Going into phpMyAdmin as specified above and running index on each comment_date_gmt for each account worked like a charm. Normally when upgrading I swap each wp-config.php with one that has a privileged db user account. I am certain that if I had done this prior to running WPAU I would not have had the comment_date_gmt problem on those new accounts.

    Your phpMyAdmin solution was really quick and easy. It took my less time to fix half a dozen blogs then type this comment… Good work!

Post a Comment

Your email address is never published nor shared. Required fields are marked *

*
*