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-admin/includes/upgrade.php

    r32310 r32364  
    528528        upgrade_420();
    529529
    530     if ( $wp_current_db_version < 32308 )
     530    if ( $wp_current_db_version < 32364 )
    531531        upgrade_430();
    532532
     
    14471447    global $wp_current_db_version, $wpdb;
    14481448
    1449     if ( $wp_current_db_version < 32308 ) {
     1449    if ( $wp_current_db_version < 32364 ) {
    14501450        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1451         if ( ! $content_length ) {
    1452             $content_length = 65535;
    1453         }
     1451        if ( false === $content_length ) {
     1452            $content_length = array(
     1453                'type'   => 'byte',
     1454                'length' => 65535,
     1455            );
     1456        } elseif ( ! is_array( $content_length ) ) {
     1457            $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1458            $content_length = array(
     1459                'type'   => 'byte',
     1460                'length' => $length
     1461            );
     1462        }
     1463
     1464        if ( 'byte' !== $content_length['type'] ) {
     1465            // Sites with malformed DB schemas are on their own.
     1466            return;
     1467        }
     1468
     1469        $allowed_length = intval( $content_length['length'] ) - 10;
    14541470
    14551471        $comments = $wpdb->get_results(
    1456             "SELECT comment_ID FROM $wpdb->comments
    1457             WHERE comment_date_gmt > '2015-04-26'
    1458             AND CHAR_LENGTH( comment_content ) >= $content_length
    1459             AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1472            "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1473                WHERE `comment_date_gmt` > '2015-04-26'
     1474                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1475                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    14601476        );
    14611477
Note: See TracChangeset for help on using the changeset viewer.