A very annoying Wordpress bug, and a fix

#1355 (General category always assigned) - WordPress Trac - Trac

So basically, whenever you post with an external client, no matter what categories you select, your default category is ALSO assigned. This is particularly annoying when you use your category in your nicely formatted URLs, because the default cat is often the one that gets used (I guess because it’s the first one encountered in the DB query), and pings sent out when you post will reference and URL with the default cat in it. Removing the default cat from that post will then result in “not found” errors.

This problem was first reported in April. I’m kind of bummed that a couple releases have gone by with no one taking a couple minutes to patch the code. For now, I’m doing it manually, but if another release comes out without it and I have to do some diff/patching shit, I’ll be very annoyed.

Rarr!

Update: The patching directions in the forum thread are a little misleading, as the new 1.5.1.3 version of xmlrpc.php has changed a lot, so line numbers are quite different. Here’s what I did to get it working.

Old:

620   } else {
621     $post_category[] = $post_default_category;
622   }

New:

620   } elseif (!$post_category) {
621     $post_category[] = $post_default_category;
622   }