Can't save emoji in custom product options #12058
Labels
Fixed in 2.2.x
The issue has been fixed in 2.2 release line
Fixed in 2.3.x
The issue has been fixed in 2.3 release line
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Issue: Format is valid
Gate 1 Passed. Automatic verification of issue format passed
Issue: Ready for Work
Gate 4. Acknowledged. Issue is added to backlog and ready for development
Reproduced on 2.1.x
The issue has been reproduced on latest 2.1 release
Reproduced on 2.2.x
The issue has been reproduced on latest 2.2 release
Reproduced on 2.3.x
The issue has been reproduced on latest 2.3 release
Preconditions
Steps to reproduce
Expected result
Actual result
My observations
The issues seem to be because Magento uses utf8_general_ci collation for the tables and also connection. If I try to manually insert "123 😍" in the utf8_general_ci table in the database, it doesn't allow it and shows following error:
[HY000][1366] Incorrect string value: '\xF0\x9F\x98\x8D' for column 'value' at row 1
Everything would be good if Magento wouldn't serialize ( or json_encode in the newest version ) the custom_options. ( well, not good anyway, but at least the cart would render fine, just the options would be truncated )
For example, when Magento inserts the "123 😍" in the quote_item_option.vale table, it becomes:
a:5:{i:0;s:8:"123
As you can see, the string is corrupted at the end ( it truncates the string at the place where the emoji is )
I think that even if you do not plan to switch from utf8_general_ci to some other encoding which could solve this problem, you should still try to either show an error message in the front-end for the user or at least silently remove that emoji so that at least the cart would render fine.
Let me know what you think.
Thanks.
The text was updated successfully, but these errors were encountered: