[wp-trac] [WordPress Trac] #60362: Emojis cause "Updating failed. Could not update post in the database." error

WordPress Trac noreply at wordpress.org
Wed Aug 13 17:04:37 UTC 2025


#60362: Emojis cause "Updating failed. Could not update post in the database."
error
-------------------------------------------------+-------------------------
 Reporter:  mikefitzman                          |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Database                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-test-info needs-testing needs-   |     Focuses:
  screenshots                                    |
-------------------------------------------------+-------------------------

Comment (by slaFFik):

 I was shot in a foot today with this problem, some commands I ran to fix
 the issue.

 List all tables that are not `utf8mb4`:

 {{{
 SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME,
 COLLATION_NAME
 FROM information_schema.COLUMNS
 WHERE TABLE_SCHEMA = 'DATABASE_NAME'
   AND CHARACTER_SET_NAME <> 'utf8mb4';
 }}}

 Don't forget to change `DATABASE_NAME` to your database name.

 ---

 Here is a wp-cli command to fix it on a per table basis:

 {{{
 wp db query "ALTER TABLE wp_posts CONVERT TO CHARACTER SET utf8mb4 COLLATE
 utf8mb4_unicode_ci;"
 }}}

 Don't forget to change the `wp_posts` table to the one you want to fix.

 ---

 You can also fix that in a loop for all tables using a bash script:

 {{{
 for t in $(wp db tables); do
   wp db query "ALTER TABLE $t CONVERT TO CHARACTER SET utf8mb4 COLLATE
 utf8mb4_unicode_ci;"
 done
 }}}

 ---

 But ideally a new `if` check(s) should be added to
 `\wpdb::process_fields()` and/or `\wpdb::strip_invalid_text()` methods
 that will notify specifically about emojis.

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


More information about the wp-trac mailing list