Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 9624)
+++ wp-includes/taxonomy.php	(working copy)
@@ -797,14 +797,16 @@
 	$else_where = 't.name = %s';
 
 	if ( !empty($taxonomy) ) {
-		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) )
-			return $result;
+		if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT t.name, tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s", $slug, $taxonomy), ARRAY_A) )
+			if ( 0 == strcmp($result['name'], $term) )
+				return $result;
 
 		return $wpdb->get_row( $wpdb->prepare("SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s", $term, $taxonomy), ARRAY_A);
 	}
 
-	if ( $result = $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $where", $slug) ) )
-		return $result;
+	if ( $result = $wpdb->get_row( $wpdb->prepare("SELECT term_id, name FROM $wpdb->terms as t WHERE $where", $slug), ARRAY_A ) )
+		if ( 0 == strcmp($result['name'], $term) )
+			return $result['term_id'];
 
 	return $wpdb->get_var( $wpdb->prepare("SELECT term_id FROM $wpdb->terms as t WHERE $else_where", $term) );
 }
@@ -1265,19 +1267,13 @@
 			$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $alias->term_id ) );
 		}
 	}
+	if ( $term_id = is_term($name, $taxonomy) )
+		return new WP_Error('term_exists', __('A term by this name allready exists'));
 
-	if ( ! $term_id = is_term($slug) ) {
-		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
-			return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
-		$term_id = (int) $wpdb->insert_id;
-	} else 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);
-		if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
-			return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
-		$term_id = (int) $wpdb->insert_id;
-	}
+	$slug = wp_unique_term_slug($slug, (object) $args);
+	if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
+		return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
+	$term_id = (int) $wpdb->insert_id;
 
 	if ( empty($slug) ) {
 		$slug = sanitize_title($slug, $term_id);
