﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
5096	wp_set_post_categories fails if input array index starts with other than 0	borgar	ryan	"wp_set_post_categories is defected in that if it is passed a an array of categories who's index starts at other than 0, it returns without any action. I noticed this when tracking another issue in Textpattern import.

Example:

{{{
$cats = array();
$cats[1] = 10;
wp_set_post_categories($postID, $cats);
}}}

This fails because {{{(1==count($cats) && ''==$cats[ 0 ]) == true}}}.

Further, I feel that inconsistent checking behavior needs addressing. Why should this function return true in the single case where it gets an array of values where {{{[0]==''}}} ?

My suggestion is to use this:

{{{
if (!is_array($post_categories) || '' == implode($post_categories))
  $post_categories = array(get_option('default_category'));
}}}"	defect (bug)	closed	normal		Taxonomy	2.3	normal	duplicate	has-patch	kevinB wojtek.szkutnik@…
