Make WordPress Core


Ignore:
Timestamp:
05/06/2015 07:16:41 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.7 branch.

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

See #32165.

File:
1 edited

Legend:

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

    r32318 r32391  
    412412                upgrade_373();
    413413
    414         if ( $wp_current_db_version < 26150 )
    415                 upgrade_378();
     414        if ( $wp_current_db_version < 26151 )
    416415
    417416        maybe_disable_link_manager();
     
    12791278 */
    12801279function upgrade_378() {
     1280}
     1281
     1282/**
     1283 * Execute changes made in WordPress 3.7.9.
     1284 *
     1285 * @since 3.7.9
     1286 */
     1287function upgrade_379() {
    12811288        global $wp_current_db_version, $wpdb;
    12821289
    1283         if ( $wp_current_db_version < 26150 ) {
     1290        if ( $wp_current_db_version < 26151 ) {
    12841291                $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1285                 if ( ! $content_length ) {
    1286                         $content_length = 65535;
    1287                 }
     1292                if ( false === $content_length ) {
     1293                        $content_length = array(
     1294                                'type'   => 'byte',
     1295                                'length' => 65535,
     1296                        );
     1297                } elseif ( ! is_array( $content_length ) ) {
     1298                        $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1299                        $content_length = array(
     1300                                'type'   => 'byte',
     1301                                'length' => $length
     1302                        );
     1303                }
     1304
     1305                if ( 'byte' !== $content_length['type'] ) {
     1306                        // Sites with malformed DB schemas are on their own.
     1307                        return;
     1308                }
     1309
     1310                $allowed_length = intval( $content_length['length'] ) - 10;
    12881311
    12891312                $comments = $wpdb->get_results(
    1290                         "SELECT comment_ID FROM $wpdb->comments
    1291                         WHERE comment_date_gmt > '2015-04-26'
    1292                         AND CHAR_LENGTH( comment_content ) >= $content_length
    1293                         AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1313                        "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1314                                WHERE `comment_date_gmt` > '2015-04-26'
     1315                                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1316                                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    12941317                );
    12951318
Note: See TracChangeset for help on using the changeset viewer.