Opened 4 weeks ago
Last modified 3 weeks ago
#66072 new defect (bug)
Database tests fail on MariaDB 13.1 because utf8 now resolves to utf8mb4
| Reported by: | andraganescu | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Database | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Reported by @danielblack in core Slack.
MariaDB 13.1.1 removes UTF8_IS_UTF8MB3 from the default old_mode (MDEV-30041), so the charset name utf8 now means utf8mb4 instead of utf8mb3 in DDL and SET NAMES. This breaks 4 tests in Tests_DB_Charset (seen on MariaDB's own WordPress buildbot): test_get_table_charset, test_get_column_charset, test_strip_invalid_text_from_query, and test_set_charset_changes_the_connection_collation.
They fail because the test file's $utf8_is_utf8mb3 flag (tests/phpunit/tests/db/charset.php:62-66) is set by a version check ("MariaDB ≥ 10.6.1"), which only accounts for the 10.6 change in how the server reports the charset, not the 13.1 change in what the name utf8 creates. Core's runtime is fine — wpdb::determine_charset() has upgraded utf8 to utf8mb4 since 4.6 — this is purely a test-expectation fix.
Change History (6)
This ticket was mentioned in Slack in #core by andraganescu. View the logs.
4 weeks ago
#3
@
4 weeks ago
Thanks for reporting this! I dug into it and was able to reproduce the issue on trunk.
It looks like maybe_convert_table_to_utf8mb4() doesn't currently recognize the utf8mb3 collation as upgradeable. Adding utf8mb3 to the allowed charset check should do the trick, which aligns perfectly with the fix suggested in the report.
While looking through the code, I noticed that determine_charset() seems to share this same issue. What do you all think would it be better to bundle both fixes into a single PR, or should we keep them separate for easier review? Happy to go with whatever approach works best!
This ticket was mentioned in PR #13497 on WordPress/wordpress-develop by @micahele.
3 weeks ago
#5
- Keywords has-patch has-unit-tests added; needs-patch removed
On MariaDB 13.1, four database tests fail. MariaDB changed what the utf8 character set name means. It used to mean the older 3-byte version (utf8mb3), and now it means utf8mb4.
WordPress itself isn't affected. Only the tests are, because they used utf8 and expected the old meaning.
This PR updates the tests so they say exactly which character set they mean:
- Two test tables now use
utf8mb3instead ofutf8. - The collation test now uses
utf8mb4_general_ci, which gives the same result on every server.
### Testing
MariaDB 13.1 isn't on Docker Hub yet, so I ran MariaDB 11.4 with --old-mode=, which turns on the same new behavior.
| Server | trunk | This PR |
|---|---|---|
MariaDB 11.4 with --old-mode= (acts like 13.1) | 4 failures, the ones in the ticket | All 100 pass |
| MariaDB 11.4, default settings | Not run | All 100 pass |
| MySQL 8.4 | Not run | All 100 pass |
To run them: vendor/bin/phpunit tests/phpunit/tests/db/charset.php
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Finding the cause, writing the test changes, and running the tests on each server. I reviewed the changes and take responsibility for them.
#6
@
3 weeks ago
Update: the PR description copied in comment:5 is from before I tested on the real MariaDB 13.1.
I reproduced this on MariaDB 13.1.1, using MariaDB's dev image (quay.io/mariadb-foundation/mariadb-devel:13.1). The same 4 tests fail on trunk.
PR: https://github.com/WordPress/wordpress-develop/pull/13497
It only changes the tests. They now say utf8mb3 where they mean it, instead of relying on utf8. All tests pass on MariaDB 13.1.1, MariaDB 11.4 and MySQL 8.4.
About comment:3: as the ticket says, WordPress itself handles this fine, so I kept maybe_convert_table_to_utf8mb4() out of this PR. If there's a separate problem there, a new ticket with steps to reproduce would help.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Related #60002