palasthotel / grid-wordpress

a reference implementation of grid for wordpress
5 stars 5 forks source link

Container Title does not save Unicode #121

Closed greatestview closed 5 years ago

greatestview commented 5 years ago

When you try to save a container title with a Unicode character, e. g. an emoji, the changes won’t be stored inside the database on save, although database table and field are encoded as utf8mb4.

Steps to reproduce:

  1. Create a new container.
  2. Fill the container title with some text and an emoji, e. g. Test πŸ™ˆπŸ€·β€β™‚οΈπŸ˜±.
  3. Click save.
  4. Everything seems right, but if you look closely into the database, the changes are gone.
  5. Reload the browser -> the changes are gone.
EdwardBock commented 5 years ago

There is a mysql error Incorrect string value: '\xF0\x9F\x99\x88\xF0\x9F...' for column 'title' at row 1 but not with all instances. My dev wordpress has no problem, but one of our projects has.

EdwardBock commented 5 years ago

So it depends on the used emojies. πŸ™ˆπŸ€·β€β™‚οΈπŸ˜±these ones always make trouble. I changed the column collation to utf8mb4_unicode_520_ci and then the error is gone but the result is not what I want.

Bildschirmfoto 2019-05-31 um 13 09 31
EdwardBock commented 5 years ago

@mkernel

I think I need your help with this:

https://github.com/palasthotel/grid/tree/121-emoji-encoding

EdwardBock commented 5 years ago

We will write a unit test which only writes and reads string with emojies

EdwardBock commented 5 years ago

@greatestview

No easy fight but I think I won! πŸŽ‰

https://github.com/palasthotel/grid/commit/6edd69ed7657d7b32b8cc14c115fdf7f2525b4e9