Fix: Improve Charset Handling in wpdb::get_table_charset Method#7662
Fix: Improve Charset Handling in wpdb::get_table_charset Method#7662Debarghya-Banerjee wants to merge 3 commits intoWordPress:trunkfrom
wpdb::get_table_charset Method#7662Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
apermo
left a comment
There was a problem hiding this comment.
Other than the likely by accident added empty line. Looking good to me.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac Ticket: Core-59868
Summary
wpdb::get_table_charsetfunction regarding character set determination for database tables with mixed charset definitions. The previous implementation prioritized utf8 when both utf8 and utf8mb4 were present, leading to potential data loss for 4-byte characters (e.g., emojis). This change ensures that utf8mb4 is used when applicable.Changes Made
Updated Charset Logic:
The logic in the get_table_charset function was modified to return utf8mb4 when both
utf8andutf8mb4character sets are detected in the table's columns.This ensures that columns defined with utf8mb4 can store all valid characters, including 4-byte characters.
Test Updates:
Tests_DB_Charset::test_get_table_charsetto reflect the new behavior, specifically modifying expectations where the charset was previously set to utf8 when utf8mb4 should now be expected.Rationale
Impact
Testing
Updated tests to reflect new charset logic.
All tests have been run and passed successfully.