From 733e06315ac80a08504cea582372283c74070502 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 8 May 2015 12:21:18 +0000 Subject: [PATCH] Upgrades: If a table has already been converted to `utf8mb4`, there's no need to try and convert it again. Props gabrielperezs for the initial patch. See #32310. git-svn-id: https://develop.svn.wordpress.org/trunk@32456 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/upgrade.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index a8b4c740a5..dde618ab02 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -1751,6 +1751,17 @@ function maybe_convert_table_to_utf8mb4( $table ) { } } + $table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" ); + if ( ! $table_details ) { + return false; + } + + list( $table_charset ) = explode( '_', $table_details->Collation ); + $table_charset = strtolower( $table_charset ); + if ( 'utf8mb4' === $table_charset ) { + return true; + } + return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); }