WordPress.org

Make WordPress Core

Ticket #38622: 38622.diff

File 38622.diff, 857 bytes (added by kingkero, 21 months ago)
  • wp-includes/comment.php

    diff --git a/wp-includes/comment.php b/wp-includes/comment.php
    index 5e89ef7..89628aa 100644
    a b function wp_new_comment( $commentdata, $avoid_die = false ) { 
    20982098                return $commentdata['comment_approved'];
    20992099        }
    21002100
     2101        $check_max_lengths = wp_check_comment_data_max_lengths( $commentdata );
     2102        if ( is_wp_error( $check_max_lengths ) ) {
     2103                if ( true === $avoid_die ) {
     2104                        return $check_max_lengths;
     2105                } else {
     2106                        if ( wp_doing_ajax() ) {
     2107                                die( $check_max_lengths->get_error_message() );
     2108                        }
     2109
     2110                        wp_die( $check_max_lengths->get_error_message(), $check_max_lengths->get_error_code() );
     2111                }
     2112        }
     2113
    21012114        $comment_ID = wp_insert_comment( $commentdata );
    21022115        if ( ! $comment_ID ) {
    21032116                $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );