Sanity check terms. Skip term IDs that don't exist.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-04-13 14:32:30 +00:00
parent 5a76e8be5d
commit eec2968be7
1 changed files with 5 additions and 1 deletions

View File

@ -1634,8 +1634,12 @@ function wp_set_object_terms($object_id, $terms, $taxonomy, $append = false) {
if ( !strlen(trim($term)) ) if ( !strlen(trim($term)) )
continue; continue;
if ( !$term_info = is_term($term, $taxonomy) ) if ( !$term_info = is_term($term, $taxonomy) ) {
// Skip if a non-existent term ID is passed.
if ( is_int($term) )
continue;
$term_info = wp_insert_term($term, $taxonomy); $term_info = wp_insert_term($term, $taxonomy);
}
if ( is_wp_error($term_info) ) if ( is_wp_error($term_info) )
return $term_info; return $term_info;
$term_ids[] = $term_info['term_id']; $term_ids[] = $term_info['term_id'];