Make WordPress Core

Ticket #10790: 10790-2014-07-31.diff

File 10790-2014-07-31.diff, 1.5 KB (added by asannad, 10 years ago)

Updated patch against WP 3.9.1

  • wp-includes/comment-template.php

     
    11161116        if ( $user_ID) {
    11171117                $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));
    11181118        } 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 ) ) );
    11201121        } else {
    11211122                $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));
    11221123        }