The new WordPress UTW gotcha

(Later – Scroll to the end of this post for a small patch to fix the problem with disappearing tags!)

As seen elsewhere and of course on the official blog, WordPress 2.1 was released to much fanfare yesterday.

It works great, I’ve been using the development version on my blogs for quite a while now and until recently it worked swimmingly. It still does, but some time in the last 2 weeks Ultimate Tag Warrior stopped working properly. Whenever someone made a comment on a post the tags on that post would be deleted. It’s gotten so bad now that I’m moderating all comments, and opening those posts in the editor before approving the comments.

A half-way fix is available but moderated comments will still delete the tags so once I verify that the fix does what it does comment moderation will go back to the way it was before.

You should upgrade WP-Cache to the new 2.0.22 release too. It fixed problems I was seeing here with comments and posts not showing up until I deleted the cache manually. Yay!

If you’re interested, a new WordPress MU release will follow in a day or so. More here.

I forgot to mention, do I recommend you upgrade to WordPress 2.1? Yes. If you run a site that is in any way popular your database server will thank you. WordPress uses the MySQL query cache in a much more efficient manner than ever before when reading posts. Make sure your query cache is activated and tweak it until you hit the sweet spot. It’ll make a big difference when your server is under load.

Fix Fix Fix!

HandySolo spotted a simple fix for the tag problem! Check out the thread on this post and scroll to the entry by where he outlines a simple fix for the disappearing tag problem. I just tried it and it works!

Here’s a temporary patch for resetting tags.
Modify ‘ultimate_save_tags()’ function on ‘ultimate-tag-warrior-actions.php’ about line 502:
if (isset($_POST['comment_post_ID'])) return $postID;
if (isset($_POST['not_spam'])) return $postID; // akismet fix
if (isset($_POST["comment"])) return $postID; // moderation.php fix

Even with the fix above, deleting a comment will delete the tags, and sending a trackback/pingback will do the same. fixed that too. You can remove the above fix and apply the following.
Around line 862 of ultimate-tag-warrior-actions.php find the following chunk of code:

// Save changes to tags
add_action('publish_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('edit_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('save_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
add_action('wp_insert_post', array('UltimateTagWarriorActions','ultimate_save_tags'));

Replace that code with:

// Save changes to tags
add_action('save_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
if($wp_db_version < 3308 ) { // if lesser than WP 2.0
  add_action('publish_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
  add_action('edit_post', array('UltimateTagWarriorActions','ultimate_save_tags'));
  add_action('wp_insert_post', array('UltimateTagWarriorActions','ultimate_save_tags'));

PS. Stephen Spencer has discovered why UTW doesn’t always work with custom permalinks. This is a longstanding bug, and it’s why I had to use the ?tag= format on my photoblog.



51 Replies to “The new WordPress UTW gotcha”

Leave a Reply