WordPress.org

Make WordPress Core

Changeset 31263


Ignore:
Timestamp:
01/21/2015 11:03:48 PM (5 years ago)
Author:
pento
Message:

Comments: When a comment fails to insert, remove any invalid characters and try again.

See #21212

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r31195 r31263  
    19261926    $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' );
    19271927    if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
    1928         return false;
     1928        $fields = array( 'comment_author', 'comment_content' );
     1929
     1930        foreach( $fields as $field ) {
     1931            if ( isset( $compacted[ $field ] ) ) {
     1932                $post_data[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $compacted[ $field ] );
     1933            }
     1934        }
     1935
     1936        if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
     1937            return false;
     1938        }
    19291939    }
    19301940
Note: See TracChangeset for help on using the changeset viewer.