WordPress.org

Make WordPress Core

Ticket #14601: 14601.2.diff

File 14601.2.diff, 1.4 KB (added by wonderboymusic, 6 years ago)
  • wp-includes/comment.php

    diff --git wp-includes/comment.php wp-includes/comment.php
    index d3d8db6..270cafa 100644
    function wp_new_comment( $commentdata ) { 
    13841384        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
    13851385        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
    13861386
    1387         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
    1388         $commentdata['comment_agent']     = isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
    1389 
    1390         $commentdata['comment_date']     = current_time('mysql');
    1391         $commentdata['comment_date_gmt'] = current_time('mysql', 1);
     1387        if ( ! isset( $commentdata['comment_author_IP'] ) )
     1388                $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
     1389        if ( ! isset( $commentdata['comment_agent'] ) )
     1390                $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 ) : '';
     1391
     1392        if ( ! isset( $commentdata['comment_date'] ) )
     1393                $commentdata['comment_date'] = current_time( 'mysql' );
     1394        if ( ! isset( $commentdata['comment_date_gmt'] ) )
     1395                $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 );
    13921396
    13931397        $commentdata = wp_filter_comment($commentdata);
    13941398