Index: wp-includes/comment.php
===================================================================
--- wp-includes/comment.php	(revision 20681)
+++ wp-includes/comment.php	(working copy)
@@ -222,7 +222,10 @@
 			'type' => '',
 			'user_id' => '',
 			'search' => '',
-			'count' => false
+			'count' => false,
+			'cat' => false,
+			'category__in' => array(),
+			'category__not_in' => array()
 		);
 
 		$this->query_vars = wp_parse_args( $query_vars, $defaults );
@@ -301,6 +304,35 @@
 		else
 			$fields = '*';
 
+		if ( empty( $category__in ) ) {
+			$category__in = array();
+		}
+		if ( empty( $category__not_in ) ) {
+			$category__not_in = array();
+		}
+
+		if ( !empty($cat) && '0' != $cat ) {
+			$cat = ''.urldecode($cat).'';
+			$cat = addslashes_gpc($cat);
+			$cat_array = preg_split('/[,\s]+/', $cat);
+			$cat = '';
+			$req_cats = array();
+			foreach ( (array) $cat_array as $cat_id ) {
+				$cat_id = intval($cat_id);
+				$req_cats[] = $cat_id;
+				$in = ($cat_id > 0);
+				$cat_id = abs($cat_id);
+				if ( $in ) {
+					$category__in[] = $cat_id;
+					$category__in = array_merge( $category__in, get_term_children($cat_id, 'category') );
+				} else {
+					$category__not_in[] = $cat_id;
+					$category__not_in = array_merge( $category__not_in, get_term_children($cat_id, 'category') );
+				}
+			}
+			$cat = implode(',', $req_cats);
+		}
+
 		$join = '';
 		$where = $approved;
 
@@ -330,7 +362,27 @@
 			foreach( $post_fields as $field_name => $field_value )
 				$where .= $wpdb->prepare( " AND {$wpdb->posts}.{$field_name} = %s", $field_value );
 		}
+		if ( ! empty( $category__in ) || ! empty( $category__not_in ) ) {
+			if ( empty( $join ) ) {
+				$join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID";
+			}
+			$join .= " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
+			$join .= " INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
+			$where .= " AND $wpdb->term_taxonomy.taxonomy = 'category'";
 
+			if ( ! empty( $category__in ) ) {
+				$category__in = array_map( 'absint', array_unique( (array) $category__in ) );
+				$category__in_query = implode( ',', $category__in );
+				$where .= $wpdb->prepare( " AND $wpdb->term_taxonomy.term_id IN ($category__in_query)" );
+			}
+
+			if ( ! empty( $category__not_in ) ) {
+				$category__not_in = array_map( 'absint', array_unique( (array) $category__not_in ) );
+				$category__not_in_query = implode( ',', $category__not_in );
+				$where .= $wpdb->prepare( " AND $wpdb->term_taxonomy.term_id NOT IN ($category__not_in_query)" );
+			}
+		}
+
 		$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
 		$clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) );
 		foreach ( $pieces as $piece )
