WordPress.org

Make WordPress Core

Ticket #16882: patch-core-get_comments_since.diff

File patch-core-get_comments_since.diff, 1.8 KB (added by koke, 7 years ago)
  • wp-includes/comment.php

     
    213213                        'parent' => '',
    214214                        'post_ID' => '',
    215215                        'post_id' => 0,
     216                        'since' => '',
    216217                        'status' => '',
    217218                        'type' => '',
    218219                        'user_id' => '',
     
    230231                if ( !$last_changed ) {
    231232                        $last_changed = time();
    232233                        wp_cache_set('last_changed', $last_changed, 'comment');
     234                } elseif ( ( '' !== $since ) && ( $since > $last_changed ) ) {
     235                  return array();
    233236                }
    234237                $cache_key = "get_comments:$key:$last_changed";
    235238
     
    316319                        $where .= $wpdb->prepare( ' AND comment_parent = %d', $parent );
    317320                if ( '' !== $user_id )
    318321                        $where .= $wpdb->prepare( ' AND user_id = %d', $user_id );
     322                if ( '' !== $since )
     323                        $where .= $wpdb->prepare( ' AND comment_date_gmt > %s', $since );
    319324                if ( '' !== $search )
    320325                        $where .= $this->get_search_sql( $search, array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) );
    321326
  • wp-includes/class-wp-xmlrpc-server.php

     
    10591059                if ( isset($struct['number']) )
    10601060                        $number = absint($struct['number']);
    10611061
    1062                 $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
     1062                $since = ( isset($struct['since']) ) ? $struct['since'] : '' ;
     1063
     1064                $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number, 'since' => $since ) );
    10631065                $num_comments = count($comments);
    10641066
    10651067                if ( ! $num_comments )