[wp-trac] [WordPress Trac] #21212: MySQL tables should use utf8mb4 character set

WordPress Trac noreply at wordpress.org
Tue Jan 6 02:57:40 UTC 2015


#21212: MySQL tables should use utf8mb4 character set
----------------------------+-----------------------
 Reporter:  pento           |       Owner:
     Type:  task (blessed)  |      Status:  reopened
 Priority:  normal          |   Milestone:  4.2
Component:  Database        |     Version:  3.4.1
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+-----------------------

Comment (by pento):

 [attachment:21212.diff] is the first pass at automatically upgrading
 `utf8` sites to `utf8mb4`, if they support it.

 In WPDB:
 * `init_charset()` now checks to see if the MySQL server is a high enough
 version to support `utf8mb4`. This means that it needs to be run after the
 connection happens, rather than in the constructor.
 * When run on `utf8mb4` strings, it turns out that PHP's multibyte
 function transforms the invalid characters into `?`, instead of removing
 them. I upgraded the regex in `strip_invalid_text()` to handle 4 byte
 UTF-8 characters, too.

 During installation:
 * If the MySQL supports it, set `DB_CHARSET` to `utf8mb4` when `wp-
 config.php` is created.

 In the DB upgrade routines:
 * If we can do it, let's upgrade all tables to `utf8mb4`, including
 Multisite tables.

 In the Charset tests:
 * We had a couple of tests that assumed a valid 4-byte character would
 cause queries to fail. I changed it to an invalid 4-byte character.

 This gives Emoji support for everyone using MySQL 5.5+ - about 60% of
 WordPress sites. What it doesn't do:
 * Allow sites on older MySQL versions to use Emoji.
 * Allow Chrome to display Emoji. We don't need to worry about that, though
 - Emoji support landed in Chrome Canary a few weeks ago, it should be in
 the stable branch in the next couple of weeks. By the time WordPress 4.2
 is released, all Chrome users will have auto-updated.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/21212#comment:55>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list