Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 22456)
+++ wp-includes/link-template.php	(working copy)
@@ -1132,9 +1132,10 @@
 	if ( $in_same_cat || ! empty( $excluded_categories ) ) {
 		$join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
 
-		if ( $in_same_cat ) {
+		if ( $in_same_cat && is_object_in_taxonomy( $post->post_type, 'category' ) ) {
 			$cat_array = wp_get_object_terms($post->ID, 'category', array('fields' => 'ids'));
-			$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
+			if ( $cat_array )
+				$join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode(',', $cat_array) . ")";
 		}
 
 		$posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
