Index: wp-includes/default-widgets.php
===================================================================
--- wp-includes/default-widgets.php	(revision 11817)
+++ wp-includes/default-widgets.php	(working copy)
@@ -618,36 +618,47 @@
 	}
 
 	function flush_widget_cache() {
-		wp_cache_delete('recent_comments', 'widget');
+		wp_cache_delete('widget_recent_comments', 'widget');
 	}
 
 	function widget( $args, $instance ) {
-		global $wpdb, $comments, $comment;
+		global $comments, $comment;
 
+		$cache = wp_cache_get('widget_recent_comments', 'widget');
+
+		if ( ! is_array( $cache ) )
+			$cache = array();
+		
+		if ( isset( $cache[$args['widget_id']] ) ) {
+			echo $cache[$args['widget_id']];
+			return;
+		}
+
+		ob_start();
 		extract($args, EXTR_SKIP);
 		$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
-		if ( !$number = (int) $instance['number'] )
+		if ( ! $number = (int) $instance['number'] )
 			$number = 5;
 		else if ( $number < 1 )
 			$number = 1;
-		else if ( $number > 15 )
-			$number = 15;
 
-		if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
-			$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15");
-			wp_cache_add( 'recent_comments', $comments, 'widget' );
+		$comments = get_comments(array('number' => $number));
+
+		echo $before_widget;
+		if ( $title ) 
+			echo $before_title . $title . $after_title;
+
+		echo '<ul id="recentcomments">';
+		if ( $comments ) { 
+			foreach ( (array) $comments as $comment) {
+				echo  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
+			}
 		}
+		echo '</ul>';
+		echo $after_widget;
 
-		$comments = array_slice( (array) $comments, 0, $number );
-?>
-		<?php echo $before_widget; ?>
-			<?php if ( $title ) echo $before_title . $title . $after_title; ?>
-			<ul id="recentcomments"><?php
-			if ( $comments ) : foreach ( (array) $comments as $comment) :
-			echo  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
-			endforeach; endif;?></ul>
-		<?php echo $after_widget; ?>
-<?php
+		$cache[$args['widget_id']] = ob_get_flush();
+		wp_cache_add('widget_recent_comments', 'widget');
 	}
 
 	function update( $new_instance, $old_instance ) {
