From 029f637aa56f4181e69fe7b8425c92d990460e22 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 6 Feb 2015 05:58:15 +0000 Subject: [PATCH] Upgrades: When upgrading a table to utf8mb4, we should run the `ALTER TABLE` query, even if it doesn't have any text columns. This will update the table's default character set, so that any text columns added in the future will have the expected character set. See #21212 git-svn-id: https://develop.svn.wordpress.org/trunk@31354 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/upgrade.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 1b88eb3690..58263d2653 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -1662,25 +1662,17 @@ function maybe_convert_table_to_utf8mb4( $table ) { return false; } - $has_utf8 = false; foreach ( $results as $column ) { if ( $column->Collation ) { list( $charset ) = explode( '_', $column->Collation ); $charset = strtolower( $charset ); - if ( 'utf8' === $charset ) { - $has_utf8 = true; - } elseif ( 'utf8mb4' !== $charset ) { + if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { // Don't upgrade tables that have non-utf8 columns. return false; } } } - if ( ! $has_utf8 ) { - // Don't bother upgrading tables that don't have utf8 columns. - return false; - } - return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); }