[wp-hackers] Wordpress minor versions changing things for no reason, why?

Mike Purvis mike at uwmike.com
Fri Oct 12 05:20:38 GMT 2007


> I'd like to know what they are. Are you sure they're trivial?

Okay, ready for it?

Something changed between 2.2 and 2.3 that made this code stop working:

$cat_id = get_cat_id($_POST['cat_name']);
$post_cats = wp_get_post_cats('', $post_id);
$post_cats[] = $cat_id;
wp_set_post_cats('', $post_id, $post_cats);

Looks pretty vanilla, right? Well, the change had to do with the fact
that get_cat_id returns and integer, whereas wp_get_post_cats returns
an array of strings. And wp_set_post_cats now (as of some recent
change) expects an array of string-formatted numbers rather than
arbitrary numerics, so that the corrected code looks like this:

$cat_id = (string)get_cat_id($_POST['cat_name']);
$post_cats = wp_get_post_cats('', $post_id);
$post_cats[] = $cat_id;
wp_set_post_cats('', $post_id, $post_cats);

Draw your own conclusions.


More information about the wp-hackers mailing list