From fdb786ba7f37de197aecebc09be6974b930d77a8 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 20 Jun 2007 22:06:29 +0000 Subject: [PATCH] Don't create '0' categories. fixes #4413 git-svn-id: https://develop.svn.wordpress.org/trunk@5739 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 2 ++ wp-includes/taxonomy.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/wp-includes/post.php b/wp-includes/post.php index 56e78a3451..7486b43f91 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -796,6 +796,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) { // If $post_categories isn't already an array, make it one: if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) $post_categories = array(get_option('default_category')); + else if ( 1 == count($post_categories) && '' == $post_categories[0] ) + return true; $post_categories = array_map('intval', $post_categories); $post_categories = array_unique($post_categories); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index d47ab7e830..a13badc8ac 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -381,6 +381,8 @@ function is_term($term, $taxonomy = '') { global $wpdb; if ( is_int($term) ) { + if ( 0 == $term ) + return 0; $where = "t.term_id = '$term'"; } else { if ( ! $term = sanitize_title($term) ) @@ -600,6 +602,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { if ( ! is_taxonomy($taxonomy) ) return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); + if ( is_int($term) && 0 == $term ) + return new WP_Error('invalid_term_id', __('Invalid term ID')); + $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); $args = wp_parse_args($args, $defaults); $args['name'] = $term;