Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 18078)
+++ wp-includes/taxonomy.php	(working copy)
@@ -1502,10 +1502,10 @@
  */
 function sanitize_term($term, $taxonomy, $context = 'display') {
 
-	if ( 'raw' == $context )
-		return $term;
+	//if ( 'raw' == $context ) //sanitize_term_field returns when raw after int'ing appropriate fields.
+	//	return $term;
 
-	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group');
+	$fields = array('term_id', 'name', 'description', 'slug', 'count', 'parent', 'term_group', 'term_taxonomy_id');
 
 	$do_object = false;
 	if ( is_object($term) )
@@ -1558,7 +1558,7 @@
  * @return mixed sanitized field
  */
 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) {
-	if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) {
+	if ( 'parent' == $field  || 'term_id' == $field || 'count' == $field || 'term_group' == $field || 'term_taxonomy_id' == $field ) {
 		$value = (int) $value;
 		if ( $value < 0 )
 			$value = 0;
@@ -1886,12 +1886,21 @@
 	$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";
 
 	if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
-		$terms = array_merge($terms, $wpdb->get_results($query));
+		$_terms = $wpdb->get_results($query);
+		foreach ( $_terms as &$term )
+			$term = sanitize_term($term, $taxonomy, 'raw');
+		$terms = array_merge($terms, $_terms);
 		update_term_cache($terms);
 	} else if ( 'ids' == $fields || 'names' == $fields ) {
-		$terms = array_merge($terms, $wpdb->get_col($query));
+		$_terms = $wpdb->get_col($query);
+		$_field = ('ids' == $fields) ? 'term_id' : 'name';
+		foreach ( $_terms as &$term )
+			$term = sanitize_term_field( $_field, $term, $term, $taxonomy, 'raw');
+		$terms = array_merge($terms, $_terms);
 	} else if ( 'tt_ids' == $fields ) {
 		$terms = $wpdb->get_col("SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");
+		foreach ( $terms as &$tt_id )
+			$tt_id = sanitize_term_field( 'term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw'); // 0 should be the term id, however is not needed when using raw context.
 	}
 
 	if ( ! $terms )

