Make WordPress Core

Opened 6 months ago

Last modified 6 months ago

#60002 new defect (bug)

maybe_convert_table_to_utf8mb4() not work with new version of MySQL/MariaDB.

Reported by: okvee's profile okvee Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


From [this document]( They said:
From MariaDB 10.6, utf8 is by default an alias for utf8mb3

And from [this document]( in MySQL. They said:
Historically, MySQL has used utf8 as an alias for utf8mb3; beginning with MySQL 8.0.28, utf8mb3 is used exclusively in the output of SHOW statements and in Information Schema tables when this character set is meant.

It can be refer to [this issue](

So, from this simple MySQL code:

CREATE TABLE testing (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    name varchar(50) DEFAULT NULL,
    PRIMARY KEY (id)

If you run on MariaDB 10.6 or newer (for me it is 10.6.7) the utf8 column will be automatically changed to utf8mb3_general_ci.

But, WordPress function maybe_convert_table_to_utf8mb4() contain this condition:

if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) {
    // Don't upgrade tables that have non-utf8 columns.
    return false;

Which will be result in no change from utf8mb3_general_ci to utf8mb4_unicode_ci.

Change History (1)

#1 @ayeshrajans
6 months ago

Tested with MySQL 8.2, and SHOW FULL COLUMNS FROM $table indeed returns utf8mb3_... as the collation name. So I think you are right, that we need to change that line to something like this:

if ( 'utf8' !== $charset && 'utf8mb3' !== $charset && 'utf8mb4' !== $charset ) {
Note: See TracTickets for help on using tickets.