Make WordPress Core


Ignore:
Timestamp:
04/27/2015 04:03:48 PM (10 years ago)
Author:
pento
Message:

When upgrading to 4.2.1, delete suspicious comments.

File:
1 edited

Legend:

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

    r32108 r32308  
    527527    if ( $wp_current_db_version < 31351 )
    528528        upgrade_420();
     529
     530    if ( $wp_current_db_version < 32308 )
     531        upgrade_421();
    529532
    530533    maybe_disable_link_manager();
     
    14371440
    14381441/**
     1442 * Execute changes made in WordPress 4.2.1.
     1443 *
     1444 * @since 4.2.1
     1445 */
     1446function upgrade_421() {
     1447    global $wp_current_db_version, $wpdb;
     1448
     1449    if ( $wp_current_db_version < 32308 ) {
     1450        $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
     1451        if ( ! $content_length ) {
     1452            $content_length = 65535;
     1453        }
     1454
     1455        $comments = $wpdb->get_results(
     1456            "SELECT comment_ID FROM $wpdb->comments
     1457            WHERE comment_date_gmt > '2015-04-26'
     1458            AND CHAR_LENGTH( comment_content ) >= $content_length
     1459            AND ( comment_content LIKE '%<%' OR comment_content LIKE '%>%' )"
     1460        );
     1461
     1462        foreach ( $comments as $comment ) {
     1463            wp_delete_comment( $comments->comment_ID );
     1464        }
     1465    }
     1466}
     1467
     1468/**
    14391469 * Executes network-level upgrade routines.
    14401470 *
Note: See TracChangeset for help on using the changeset viewer.