Make WordPress Core


Ignore:
Timestamp:
05/06/2015 07:11:47 PM (11 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 3.9 branch.

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

See #32165.

File:
1 edited

Legend:

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

    r32316 r32389  
    431431                upgrade_380();
    432432
    433         if ( $wp_current_db_version < 27917 )
    434                 upgrade_396();
     433        if ( $wp_current_db_version < 27918 )
     434                upgrade_397();
    435435
    436436        maybe_disable_link_manager();
     
    12811281 */
    12821282function upgrade_396() {
     1283}
     1284
     1285/**
     1286 * Execute changes made in WordPress 3.9.7.
     1287 *
     1288 * @since 3.9.7
     1289 */
     1290function upgrade_397() {
    12831291        global $wp_current_db_version, $wpdb;
    12841292
    1285         if ( $wp_current_db_version < 27917 ) {
     1293        if ( $wp_current_db_version < 27918 ) {
    12861294                $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1287                 if ( ! $content_length ) {
    1288                         $content_length = 65535;
    1289                 }
     1295                if ( false === $content_length ) {
     1296                        $content_length = array(
     1297                                'type'   => 'byte',
     1298                                'length' => 65535,
     1299                        );
     1300                } elseif ( ! is_array( $content_length ) ) {
     1301                        $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1302                        $content_length = array(
     1303                                'type'   => 'byte',
     1304                                'length' => $length
     1305                        );
     1306                }
     1307
     1308                if ( 'byte' !== $content_length['type'] ) {
     1309                        // Sites with malformed DB schemas are on their own.
     1310                        return;
     1311                }
     1312
     1313                $allowed_length = intval( $content_length['length'] ) - 10;
    12901314
    12911315                $comments = $wpdb->get_results(
    1292                         "SELECT comment_ID FROM $wpdb->comments
    1293                         WHERE comment_date_gmt > '2015-04-26'
    1294                         AND CHAR_LENGTH( comment_content ) >= $content_length
    1295                         AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1316                        "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1317                                WHERE `comment_date_gmt` > '2015-04-26'
     1318                                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1319                                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    12961320                );
    12971321
Note: See TracChangeset for help on using the changeset viewer.