mybb / merge-system

The MyBB Merge System allows for easy merging of an existing forum (be it MyBB or another forum software) into a MyBB 1.8.x forum.
Other
34 stars 33 forks source link

UTF-8 sequence check when storing data on SQL query #235

Closed yuliu closed 3 years ago

yuliu commented 4 years ago

I encounter a MySQL error of invalid UTF-8 sequence when Merge is storing datatrace of records to be converted from tables using a non UTF-8 character-set.

No such error on MySQL 5.5, but the error appears on MySQL 5.7 (haven't checked 5.6). It should relate to MySQL but not PHP. However, I haven't found any reference to UTF-8 sequence check yet. Will continue investigation later.

yuliu commented 4 years ago

It's should be relating to MySQL's strict mode: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html . MySQL has some changes on its strict mode since 5.7. I haven't tested the Merge with PostgreSQL or SQLite.

Since this issue only occurs when storing datatrace on records that are being inserted, there are several ways to fix, but I'm not sure which is the best one:

For MySQL users using 5.7 or higher, there are some methods to mitigate this issue:

euantorano commented 3 years ago

Another possible approach:

In the data trace, rather than just using var_export rebuild the array and either skip or empty any strings that look like binary (e.g. preg_match('//u', $field) fails).