Make WordPress Core


Ignore:
Timestamp:
05/06/2015 07:08:42 PM (10 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.0 branch.

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

See #32165.

File:
1 edited

Legend:

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

    r32313 r32388  
    441441        upgrade_400();
    442442
    443     if ( $wp_current_db_version < 29631 )
    444         upgrade_404();
     443    if ( $wp_current_db_version < 29632 )
     444        upgrade_405();
    445445
    446446    maybe_disable_link_manager();
     
    13361336 */
    13371337function upgrade_404() {
     1338}
     1339
     1340/**
     1341 * Execute changes made in WordPress 4.0.5.
     1342 *
     1343 * @since 4.0.5
     1344 */
     1345function upgrade_405() {
    13381346    global $wp_current_db_version, $wpdb;
    13391347
    1340     if ( $wp_current_db_version < 29631 ) {
     1348    if ( $wp_current_db_version < 29632 ) {
    13411349        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1342         if ( ! $content_length ) {
    1343             $content_length = 65535;
    1344         }
     1350        if ( false === $content_length ) {
     1351            $content_length = array(
     1352                'type'   => 'byte',
     1353                'length' => 65535,
     1354            );
     1355        } elseif ( ! is_array( $content_length ) ) {
     1356            $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1357            $content_length = array(
     1358                'type'   => 'byte',
     1359                'length' => $length
     1360            );
     1361        }
     1362
     1363        if ( 'byte' !== $content_length['type'] ) {
     1364            // Sites with malformed DB schemas are on their own.
     1365            return;
     1366        }
     1367
     1368        $allowed_length = intval( $content_length['length'] ) - 10;
    13451369
    13461370        $comments = $wpdb->get_results(
    1347             "SELECT comment_ID FROM $wpdb->comments
    1348             WHERE comment_date_gmt > '2015-04-26'
    1349             AND CHAR_LENGTH( comment_content ) >= $content_length
    1350             AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1371            "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1372                WHERE `comment_date_gmt` > '2015-04-26'
     1373                AND LENGTH( `comment_content` ) >= {$allowed_length}
     1374                AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    13511375        );
    13521376
Note: See TracChangeset for help on using the changeset viewer.