From bad2c9e571dc710986ebd3f1d23e1a5f5bc7b99a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 14 Jan 2019 12:07:55 +0100 Subject: [PATCH] fix SQL error for MariaDB 10.3 on inserting 4-byte utf-8 chars enabling the replacement now uncoditional for MySQL/MariaDB --- api/src/Db.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/Db.php b/api/src/Db.php index 52bee58e34..bebc99ec82 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -1492,10 +1492,11 @@ class Db // for boolean types, causing it to return "true" or "false" and not a quoted string like "'1'"! if (is_bool($value)) $value = (string)$value; - // MySQL and MariaDB before 10.1 need 4-byte utf8 chars replaced with our default utf8 charset + // MySQL and MariaDB not 10.1 need 4-byte utf8 chars replaced with our default utf8 charset // (MariaDB 10.1 does the replacement automatic, 10.0 cuts everything off behind and MySQL gives an error) + // (MariaDB 10.3 gives an error too: Incorrect string value: '\xF0\x9F\x98\x8A\x0AW...') // Changing charset to utf8mb4 requires schema update, shortening of some indexes and probably have negative impact on performace! - if (substr($this->Type, 0, 5) == 'mysql' && $this->ServerInfo['version'] < 10.1) + if (substr($this->Type, 0, 5) == 'mysql') { $value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value); }