Opened 3 months ago
Closed 3 months ago
#23495 closed defect (bug) (duplicate)
Special characters can truncate WP Option value
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Database | Version: | |
| Severity: | normal | Keywords: | |
| Cc: |
Description
I recently experienced something weird when adding a string from a foreign language as the value of a WP Option.
Try this:
add_option( 'weird_character_test', 'test1𠆢test2' );
This will only be saved as "test1" in the wp_options table, as one can see after
echo get_option( 'weird_character_test' );
or quicker on /wp-admin/options.php.
Could this be UTF8 related? DB collation is "utf8_general_ci". Or could it be the result of sanization?
Change History (4)
- Keywords close added
Thanks for testing.
I've played with this some more, and it seems more of a mySQL thing.
I can confirm it on several different sites, with the easiest way being copying the string
test1𠆢test2
into any text field on /wp-admin/options.php and saving.
But then I could also reproduce it by adding that string to wp_options directly via PHPMyAdmin.
After checking some of the many settings in the mySQL config that are related to character encodings, I found that those are not very consistent, and that that's maybe the reason for the issues.
So, this is not a WP issue, but a mySQL issue. The question is: Is there something we can do about or against this? Can we set more mySQL config options in regard to UTF8? Can we maybe check if the value that was just inserted/updated in the DB matches the value that is read (SELECT) immediately after the INSERT/UPDATE?
Thus, as a bug, this is invalid, but maybe someone has input on this to make it an enhancement?
I can reproduce via wp-admin/options.php (previously, I used wp-cli).
comment:4
SergeyBiryukov — 3 months ago
- Component changed from General to Database
- Keywords close removed
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
I could reproduce with a PHP script on a second page load. I guess the first one printed a cached value, which might explain comment:1. Also reproduced via wp-admin/options.php.
When trying to insert the suggested value using phpMyAdmin, I get a warning:
Warning: #1366 Incorrect string value: '\xF0\xA0\x86\xA2te...' for column 'option_value' at row 1
So, it's a 4-byte character, and this ticket a duplicate of #13590. #21212 would fix this.

Can't reproduce using trunk; also have "utf8_general_ci".