Ticket #10790: 10790-2014-07-31.diff
File 10790-2014-07-31.diff, 1.5 KB (added by , 11 years ago) |
---|
-
wp-includes/comment-template.php
1116 1116 if ( $user_ID) { 1117 1117 $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)); 1118 1118 } else if ( empty($comment_author) ) { 1119 $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') ); 1119 // attempt to sniff recent (within the last hour) anonymous comments from the current visitor 1120 $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 ) ) ); 1120 1121 } else { 1121 1122 $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)); 1122 1123 }