Make WordPress Core


Ignore:
Timestamp:
05/06/2015 02:59:50 AM (10 years ago)
Author:
pento
Message:

WPDB: When checking that a string can be sent to MySQL, we shouldn't use mb_convert_encoding(), as it behaves differently to MySQL's character encoding conversion.

Props mdawaffe, pento, nbachiyski, jorbin, johnjamesjacoby, jeremyfelt.

See #32165.

File:
1 edited

Legend:

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

    r32116 r32364  
    21192119    $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' );
    21202120    if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
    2121         $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );
    2122 
    2123         foreach( $fields as $field ) {
    2124             if ( isset( $compacted[ $field ] ) ) {
    2125                 $compacted[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $compacted[ $field ] );
    2126             }
    2127         }
    2128 
    2129         if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) {
    2130             return false;
    2131         }
     2121        return false;
    21322122    }
    21332123
     
    22532243 */
    22542244function wp_new_comment( $commentdata ) {
     2245    global $wpdb;
     2246
    22552247    if ( isset( $commentdata['user_ID'] ) ) {
    22562248        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
     
    22962288    $comment_ID = wp_insert_comment($commentdata);
    22972289    if ( ! $comment_ID ) {
    2298         return false;
     2290        $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' );
     2291
     2292        foreach( $fields as $field ) {
     2293            if ( isset( $commentdata[ $field ] ) ) {
     2294                $commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] );
     2295            }
     2296        }
     2297
     2298        $commentdata = wp_filter_comment( $commentdata );
     2299
     2300        $commentdata['comment_approved'] = wp_allow_comment( $commentdata );
     2301
     2302        $comment_ID = wp_insert_comment( $commentdata );
     2303        if ( ! $comment_ID ) {
     2304            return false;
     2305        }
    22992306    }
    23002307
Note: See TracChangeset for help on using the changeset viewer.