Make WordPress Core


Ignore:
Timestamp:
04/27/2015 05:16:29 PM (11 years ago)
Author:
pento
Message:

4.0:

  • WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.
  • When upgrading, remove any suspicious comments.
File:
1 edited

Legend:

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

    r29630 r32313  
    440440    if ( $wp_current_db_version < 29630 )
    441441        upgrade_400();
     442
     443    if ( $wp_current_db_version < 29631 )
     444        upgrade_404();
    442445
    443446    maybe_disable_link_manager();
     
    13281331
    13291332/**
     1333 * Execute changes made in WordPress 4.0.4.
     1334 *
     1335 * @since 4.0.4
     1336 */
     1337function upgrade_404() {
     1338    global $wp_current_db_version, $wpdb;
     1339
     1340    if ( $wp_current_db_version < 29631 ) {
     1341        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
     1342        if ( ! $content_length ) {
     1343            $content_length = 65535;
     1344        }
     1345
     1346        $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 '%>%' )"
     1351        );
     1352
     1353        foreach ( $comments as $comment ) {
     1354            wp_delete_comment( $comment->comment_ID, true );
     1355        }
     1356    }
     1357}
     1358
     1359/**
    13301360 * Execute network level changes
    13311361 *
Note: See TracChangeset for help on using the changeset viewer.