Web Interface: SQL error "Incorrect string value" at jts3servermodwebui_ts3cache

Started by Stefan1200, July 28, 2018, 10:39:19 AM

Previous topic - Next topic

Stefan1200

Problem:
While opening the bot settings in the web interface you get the MySQL error message "Incorrect string value" while the web interface tries to insert channel and server group names with 4 byte characters into the table jts3servermodwebui_ts3cache.

Reason:
The MySQL table jts3servermodwebui_ts3cache only use the character set utf8 and the collation utf8_unicode_ci, which only allows 3 byte Unicode characters. 4 byte Unicode characters throw the "Incorrect string value" error while inserting the string to the database table.

Solution:
Since MySQL 5.5.3 (released in early 2010) it is possible to change the character set to utf8mb4 and the collation to utf8mb4_unicode_ci. This is completely untested by me, but I think it can be tested without problems.
TRUNCATE TABLE jts3servermodwebui_ts3cache;
ALTER TABLE jts3servermodwebui_ts3cache CHANGE object_name object_name VARCHAR(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';


One change in one file of the web interface is needed, open class/dbconnect.php, change line 31 to:
if (!mysqli_set_charset($this->link, "utf8mb4")

If you want to go back to the JTS3ServerMod default:
TRUNCATE TABLE jts3servermodwebui_ts3cache;
ALTER TABLE jts3servermodwebui_ts3cache CHANGE object_name object_name VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '';


Also change back the web interface php file, open class/dbconnect.php, change line 31 to:
if (!mysqli_set_charset($this->link, "utf8")

Of course there is a second solution:
Don't use 4 bytes Unicode characters, since the TS3 client 3.1.10 don't even allow to set them. ;)

As soon as this is officially supported by Teamspeak 3, I will implement this also in the JTS3ServerMod Web Interface by default (which would raise the system requirements, but the needed MySQL server version is already 8 years old, should not be a problem for the most users).

Stefan1200

TS3 Server 3.3.0 supports 4 byte Unicode characters. The next version in the next weeks will include this fix. If you need this earlier, feel free to use the above two SQL commands now.