Make WordPress Core

Ticket #51044: 51044.diff

File 51044.diff, 1.4 KB (added by SergeyBiryukov, 4 years ago)
  • src/wp-includes/comment.php

     
    21882188
    21892189        $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
    21902190
     2191        if ( ! isset( $commentdata['comment_author_IP'] ) ) {
     2192                $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
     2193        }
     2194
     2195        if ( ! isset( $commentdata['comment_agent'] ) ) {
     2196                $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
     2197        }
     2198
    21912199        /**
    21922200         * Filters a comment's data before it is sanitized and inserted into the database.
    21932201         *
     
    22112219
    22122220        $commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0;
    22132221
    2214         if ( ! isset( $commentdata['comment_author_IP'] ) ) {
    2215                 $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
    2216         }
    22172222        $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
    22182223
    2219         if ( ! isset( $commentdata['comment_agent'] ) ) {
    2220                 $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
    2221         }
    22222224        $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
    22232225
    22242226        if ( empty( $commentdata['comment_date'] ) ) {