WordPress.org

Make WordPress Core

Ticket #14601: 14601.diff

File 14601.diff, 1.5 KB (added by wonderboymusic, 5 years ago)
  • wp-includes/comment.php

     
    13871387        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
    13881388        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
    13891389
    1390         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
    1391         $commentdata['comment_agent']     = substr($_SERVER['HTTP_USER_AGENT'], 0, 254);
     1390        if ( ! isset( $commentdata['comment_author_IP'] ) )
     1391                $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
    13921392
    1393         $commentdata['comment_date']     = current_time('mysql');
    1394         $commentdata['comment_date_gmt'] = current_time('mysql', 1);
     1393        $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
    13951394
     1395        if ( ! isset( $commentdata['comment_agent'] ) )
     1396                $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
     1397
     1398        $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
     1399
     1400        if ( ! isset( $commentdata['comment_date'] ) )
     1401                $commentdata['comment_date'] = current_time('mysql');
     1402
     1403        if ( ! isset( $commentdata['comment_date_gmt'] ) )
     1404                $commentdata['comment_date_gmt'] = current_time('mysql', 1);
     1405
    13961406        $commentdata = wp_filter_comment($commentdata);
    13971407
    13981408        $commentdata['comment_approved'] = wp_allow_comment($commentdata);