From ca13bd76d596a18eaefc2b57fd01f407741ad66c Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 8 May 2015 12:28:28 +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. Merge of [32456] to the 4.2 branch. Fixes #32310. Built from https://develop.svn.wordpress.org/branches/4.2@32457 git-svn-id: http://core.svn.wordpress.org/branches/4.2@32427 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 495d5b437d..98c015ea0a 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1759,6 +1759,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" ); }