WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/06/2015 07:06:02 PM (7 years ago)
Author:
mdawaffe
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.1 branch.

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

See #32165.

File:
1 edited

Legend:

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

    r32312 r32387  
    443443        upgrade_400();
    444444
    445     if ( $wp_current_db_version < 30134 )
    446         upgrade_414();
     445    if ( $wp_current_db_version < 30135 )
     446        upgrade_415();
    447447
    448448    maybe_disable_link_manager();
     
    13351335 * Execute changes made in WordPress 4.1.4.
    13361336 *
    1337  * @since 4.1.3
     1337 * @since 4.1.4
    13381338 */
    13391339function upgrade_414() {
     1340}
     1341
     1342/**
     1343 * Execute changes made in WordPress 4.1.5.
     1344 *
     1345 * @since 4.1.5
     1346 */
     1347function upgrade_415() {
    13401348    global $wp_current_db_version, $wpdb;
    13411349
    1342     if ( $wp_current_db_version < 30134 ) {
     1350    if ( $wp_current_db_version < 30135 ) {
    13431351        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1344         if ( ! $content_length ) {
    1345             $content_length = 65535;
    1346         }
     1352        if ( false === $content_length ) {
     1353            $content_length = array(
     1354                'type'   => 'byte',
     1355                'length' => 65535,
     1356            );
     1357        } elseif ( ! is_array( $content_length ) ) {
     1358            $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1359            $content_length = array(
     1360                'type'   => 'byte',
     1361                'length' => $length
     1362            );
     1363        }
     1364
     1365        if ( 'byte' !== $content_length['type'] ) {
     1366            // Sites with malformed DB schemas are on their own.
     1367            return;
     1368        }
     1369
     1370        $allowed_length = intval( $content_length['length'] ) - 10;
    13471371
    13481372        $comments = $wpdb->get_results(
    1349             "SELECT comment_ID FROM $wpdb->comments
    1350             WHERE comment_date_gmt > '2015-04-26'
    1351             AND CHAR_LENGTH( comment_content ) >= $content_length
    1352             AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1373            "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1374                WHERE `comment_date_gmt` > '2015-04-26'
     1375                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1376                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    13531377        );
    13541378
Note: See TracChangeset for help on using the changeset viewer.