Make WordPress Core


Ignore:
Timestamp:
05/06/2015 03:29:01 AM (9 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.

Merge of [32364] to the 4.2 branch.

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

See #32165.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/src/wp-admin/includes/upgrade.php

    r32311 r32367  
    528528        upgrade_420();
    529529
    530     if ( $wp_current_db_version < 31533 )
    531         upgrade_421();
     530    if ( $wp_current_db_version < 31534 )
     531        upgrade_422();
    532532
    533533    maybe_disable_link_manager();
     
    14451445 */
    14461446function upgrade_421() {
     1447}
     1448
     1449/**
     1450 * Execute changes made in WordPress 4.2.2.
     1451 *
     1452 * @since 4.2.2
     1453 */
     1454function upgrade_422() {
    14471455    global $wp_current_db_version, $wpdb;
    14481456
    1449     if ( $wp_current_db_version < 31533 ) {
     1457    if ( $wp_current_db_version < 31534 ) {
    14501458        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1451         if ( ! $content_length ) {
    1452             $content_length = 65535;
    1453         }
     1459        if ( false === $content_length ) {
     1460            $content_length = array(
     1461                'type'   => 'byte',
     1462                'length' => 65535,
     1463            );
     1464        } elseif ( ! is_array( $content_length ) ) {
     1465            $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1466            $content_length = array(
     1467                'type'   => 'byte',
     1468                'length' => $length
     1469            );
     1470        }
     1471
     1472        if ( 'byte' !== $content_length['type'] ) {
     1473            // Sites with malformed DB schemas are on their own.
     1474            return;
     1475        }
     1476
     1477        $allowed_length = intval( $content_length['length'] ) - 10;
    14541478
    14551479        $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 '%>%' )"
     1480            "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1481                WHERE `comment_date_gmt` > '2015-04-26'
     1482                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1483                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    14601484        );
    14611485
Note: See TracChangeset for help on using the changeset viewer.