Ticket #10790: 10790.diff
File 10790.diff, 1.6 KB (added by , 14 years ago) |
---|
-
wp-includes/comment-template.php
880 880 $comment_author_url = esc_url($commenter['comment_author_url']); 881 881 882 882 /** @todo Use API instead of SELECTs. */ 883 if ( $user_ID ) {883 if ( $user_ID ) { 884 884 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID)); 885 885 } else if ( empty($comment_author) ) { 886 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 886 // attempt to sniff recent (within the last hour) anonymous comments from the current visitor 887 $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( comment_author = '' AND comment_approved = '0' AND comment_author_IP = %s AND comment_agent = %s AND comment_date_gmt > %s ) ) ORDER BY comment_date_gmt", $post->ID, $_SERVER['REMOTE_ADDR'], substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ), gmdate( 'Y-m-d H:i:s', time() - 3600 ) ) ); 887 888 } else { 888 889 $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email)); 889 890 }