Index: tp/wp-includes/post.php
===================================================================
--- tp/wp-includes/post.php	(revision 30786)
+++ tp/wp-includes/post.php	(working copy)
@@ -3837,6 +3837,8 @@
  * @return mixed Array of affected term IDs. WP_Error or false on failure.
  */
 function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
+	global $wpdb;
+
 	$post_id = (int) $post_id;
 
 	if ( !$post_id )
@@ -3850,6 +3852,16 @@
 		if ( ',' !== $comma )
 			$tags = str_replace( $comma, ',', $tags );
 		$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
+
+		foreach ($tags as &$tag){
+			$tag = '\'' . $tag . '\'';
+		}
+		$in_clause = '(' . join( ',', $tags ) . ')';
+
+		$sql_prepared = $wpdb->prepare( "SELECT t.slug
+				FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} tt ON tt.term_id = t.term_id
+				WHERE t.name IN {$in_clause} AND tt.taxonomy = %s", $taxonomy );
+		$tags         = $wpdb->get_col( $sql_prepared );
 	}
 
 	/*
