From ebb6aa1d4a9b00cd829ec6afbed4d61d1ceb19ea Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 1 Jul 2015 07:35:24 +0000 Subject: [PATCH] Split `upgrade_430()` into two so that `split_all_shared_terms()` runs when `upgrade_430_fix_comments()` bails early. See [32814], #30261, [32364], #32165 Built from https://develop.svn.wordpress.org/trunk@33020 git-svn-id: http://core.svn.wordpress.org/trunk@32991 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 86 ++++++++++++++++++++--------------- wp-includes/version.php | 2 +- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index a3e09c86ab..03d8fd0d52 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1522,42 +1522,7 @@ function upgrade_430() { global $wp_current_db_version, $wpdb; if ( $wp_current_db_version < 32364 ) { - $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' ); - - if ( is_wp_error( $content_length ) ) { - return; - } - - if ( false === $content_length ) { - $content_length = array( - 'type' => 'byte', - 'length' => 65535, - ); - } elseif ( ! is_array( $content_length ) ) { - $length = (int) $content_length > 0 ? (int) $content_length : 65535; - $content_length = array( - 'type' => 'byte', - 'length' => $length - ); - } - - if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) { - // Sites with malformed DB schemas are on their own. - return; - } - - $allowed_length = intval( $content_length['length'] ) - 10; - - $comments = $wpdb->get_results( - "SELECT `comment_ID` FROM `{$wpdb->comments}` - WHERE `comment_date_gmt` > '2015-04-26' - AND LENGTH( `comment_content` ) >= {$allowed_length} - AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )" - ); - - foreach ( $comments as $comment ) { - wp_delete_comment( $comment->comment_ID, true ); - } + upgrade_430_fix_comments(); } if ( $wp_current_db_version < 32814 ) { @@ -1565,6 +1530,55 @@ function upgrade_430() { } } +/** + * Execute comments changes made in WordPress 4.3.0. + * + * @since 4.3.0 + * + * @global int $wp_current_db_version + * @global wpdb $wpdb + */ +function upgrade_430_fix_comments() { + global $wp_current_db_version, $wpdb; + + $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' ); + + if ( is_wp_error( $content_length ) ) { + return; + } + + if ( false === $content_length ) { + $content_length = array( + 'type' => 'byte', + 'length' => 65535, + ); + } elseif ( ! is_array( $content_length ) ) { + $length = (int) $content_length > 0 ? (int) $content_length : 65535; + $content_length = array( + 'type' => 'byte', + 'length' => $length + ); + } + + if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) { + // Sites with malformed DB schemas are on their own. + return; + } + + $allowed_length = intval( $content_length['length'] ) - 10; + + $comments = $wpdb->get_results( + "SELECT `comment_ID` FROM `{$wpdb->comments}` + WHERE `comment_date_gmt` > '2015-04-26' + AND LENGTH( `comment_content` ) >= {$allowed_length} + AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )" + ); + + foreach ( $comments as $comment ) { + wp_delete_comment( $comment->comment_ID, true ); + } +} + /** * Executes network-level upgrade routines. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 4cc970a324..2ddc948ae2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-33019'; +$wp_version = '4.3-alpha-33020'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.