Well, I finally took the plunge on WordPress 1.3. The new stuff looks pretty good, but I’m more interested in the back end running smoothly. Of course, there were a couple of issues during the upgrade.

Currently there is a problem with the comments appearing correctly when upgrading. I feel partially responsible for this because I wrote the function that upgrades the database, but it’s not my code that causes the problem. Directly.

The trick is that when converting from a numeric to an enumerated type MySQL doesn’t do anything special to the data. It shouldn’t. And although this is good for keeping the existing data intact when you change a field type, you need to know certain things about the data type when you do the conversion.

MySQL stores enumerated fields internally as numbers with an index starting at 1. So if you have an enumerated field called comment_approved defined originally as comment_approved ENUM(‘0’, ‘1’) and you convert it to tinyint(1), MySQL doesn’t convert the ‘0’ values to integer 0, it converts them to their numeric equivalent. Since ‘0’ is the first index, and enumerated indexes in MySQL start at 1, the ‘0’ is converted to the integer 1. Likewise, the enumerated value ‘1’ is converted to the integer value 2.

It seems like a crazy thing to happen, but imagine if the original enumerated type was ENUM(‘moderated’, ‘approved’). The value ‘moderated’ would convert to 1 and the value ‘approved’ would convert to 2. Nobody would complain. The problem with the 1.2 design of the database was the selection of enumerated names for that field.

Anyhow, it’s easy to fix the problem if you just run this simple query on the database:

UPDATE wp_comments SET comment_approved = comment_approved - 1;

You can do this easily using phpMyAdmin or console-mode access to MySQL. If it doesn’t execute, be sure that you’re using “wp_” as your table prefix in the WordPress database.

There is already a bug in the WordPress bug database for this along with a patch for a solution, so I’m sure it will be cured in source before the beta is available.

There is also a small issue in the current (as of this morning) CVS version of WordPress that won’t allow authorized users to publish new posts. There is an easy fix for this, too, which involves changing a boolean operator in edit-post-advanced.php. Look for two lines that include the text “new_users_can_blog”. (This is a new feature of 1.3 that sets the permissions of registered users that don’t have permissions set.)

Change those lines to look like this:

<?php if ( 2 == get_option(’new_users_can_blog’) || 1 != $user_level ) : ?>

All should be well - your Publish button should reappear.