Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 7310)
+++ wp-includes/taxonomy.php	(working copy)
@@ -1124,7 +1124,7 @@
 	if ( is_int($term) && 0 == $term )
 		return new WP_Error('invalid_term_id', __('Invalid term ID'));
 
-	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
+	$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '', 'canonical' => true);
 	$args = wp_parse_args($args, $defaults);
 	$args['name'] = $term;
 	$args['taxonomy'] = $taxonomy;
@@ -1151,10 +1151,19 @@
 		}
 	}
 
-	if ( ! $term_id = is_term($slug) ) {
-		$wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) );
-		$term_id = (int) $wpdb->insert_id;
-	} else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) {
+	if ( $canonical ) {
+		if ( ! $term_id = is_term($slug) ) {
+			$wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) );
+			$term_id = (int) $wpdb->insert_id;
+		}	
+	} else {
+		if ( ! $term_id = is_term($slug, $taxonomy) ) {
+			$wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) );
+			$term_id = (int) $wpdb->insert_id;
+			}
+	}
+	
+	if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) {
 		// If the taxonomy supports hierarchy and the term has a parent, make the slug unique
 		// by incorporating parent slugs.
 		$slug = wp_unique_term_slug($slug, (object) $args);
@@ -1162,6 +1171,9 @@
 		$term_id = (int) $wpdb->insert_id;
 	}
 
+	if ( is_array($term_id) ) 
+ 	    $term_id = $term_id['term_id'];
+	
 	if ( empty($slug) ) {
 		$slug = sanitize_title($slug, $term_id);
 		$wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );

