WordPress.org

Make WordPress Core

Changeset 33020


Ignore:
Timestamp:
07/01/2015 07:34:26 AM (6 years ago)
Author:
dd32
Message:

Split upgrade_430() into two so that split_all_shared_terms() runs when upgrade_430_fix_comments() bails early.

See [32814], #30261, [32364], #32165

File:
1 edited

Legend:

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

    r32852 r33020  
    15231523
    15241524    if ( $wp_current_db_version < 32364 ) {
    1525         $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
    1526 
    1527         if ( is_wp_error( $content_length ) ) {
    1528             return;
    1529         }
    1530 
    1531         if ( false === $content_length ) {
    1532             $content_length = array(
    1533                 'type'   => 'byte',
    1534                 'length' => 65535,
    1535             );
    1536         } elseif ( ! is_array( $content_length ) ) {
    1537             $length = (int) $content_length > 0 ? (int) $content_length : 65535;
    1538             $content_length = array(
    1539                 'type'   => 'byte',
    1540                 'length' => $length
    1541             );
    1542         }
    1543 
    1544         if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
    1545             // Sites with malformed DB schemas are on their own.
    1546             return;
    1547         }
    1548 
    1549         $allowed_length = intval( $content_length['length'] ) - 10;
    1550 
    1551         $comments = $wpdb->get_results(
    1552             "SELECT `comment_ID` FROM `{$wpdb->comments}`
    1553                 WHERE `comment_date_gmt` > '2015-04-26'
    1554                 AND LENGTH( `comment_content` ) >= {$allowed_length}
    1555                 AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
    1556         );
    1557 
    1558         foreach ( $comments as $comment ) {
    1559             wp_delete_comment( $comment->comment_ID, true );
    1560         }
     1525        upgrade_430_fix_comments();
    15611526    }
    15621527
    15631528    if ( $wp_current_db_version < 32814 ) {
    15641529        split_all_shared_terms();
     1530    }
     1531}
     1532
     1533/**
     1534 * Execute comments changes made in WordPress 4.3.0.
     1535 *
     1536 * @since 4.3.0
     1537 *
     1538 * @global int   $wp_current_db_version
     1539 * @global wpdb  $wpdb
     1540 */
     1541function upgrade_430_fix_comments() {
     1542    global $wp_current_db_version, $wpdb;
     1543
     1544    $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
     1545
     1546    if ( is_wp_error( $content_length ) ) {
     1547        return;
     1548    }
     1549
     1550    if ( false === $content_length ) {
     1551        $content_length = array(
     1552            'type'   => 'byte',
     1553            'length' => 65535,
     1554        );
     1555    } elseif ( ! is_array( $content_length ) ) {
     1556        $length = (int) $content_length > 0 ? (int) $content_length : 65535;
     1557        $content_length = array(
     1558            'type'   => 'byte',
     1559            'length' => $length
     1560        );
     1561    }
     1562
     1563    if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
     1564        // Sites with malformed DB schemas are on their own.
     1565        return;
     1566    }
     1567
     1568    $allowed_length = intval( $content_length['length'] ) - 10;
     1569
     1570    $comments = $wpdb->get_results(
     1571        "SELECT `comment_ID` FROM `{$wpdb->comments}`
     1572            WHERE `comment_date_gmt` > '2015-04-26'
     1573            AND LENGTH( `comment_content` ) >= {$allowed_length}
     1574            AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
     1575    );
     1576
     1577    foreach ( $comments as $comment ) {
     1578        wp_delete_comment( $comment->comment_ID, true );
    15651579    }
    15661580}
Note: See TracChangeset for help on using the changeset viewer.