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
This commit is contained in:
parent
0b5e8a1702
commit
029f637aa5
@ -1662,25 +1662,17 @@ function maybe_convert_table_to_utf8mb4( $table ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$has_utf8 = false;
|
|
||||||
foreach ( $results as $column ) {
|
foreach ( $results as $column ) {
|
||||||
if ( $column->Collation ) {
|
if ( $column->Collation ) {
|
||||||
list( $charset ) = explode( '_', $column->Collation );
|
list( $charset ) = explode( '_', $column->Collation );
|
||||||
$charset = strtolower( $charset );
|
$charset = strtolower( $charset );
|
||||||
if ( 'utf8' === $charset ) {
|
if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
|
||||||
$has_utf8 = true;
|
|
||||||
} elseif ( 'utf8mb4' !== $charset ) {
|
|
||||||
// Don't upgrade tables that have non-utf8 columns.
|
// Don't upgrade tables that have non-utf8 columns.
|
||||||
return false;
|
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" );
|
return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user