From 72e851ce264955d9c9c40ba5fda9f77c72100e0f Mon Sep 17 00:00:00 2001 From: jrblakely Date: Sun, 9 Oct 2022 09:37:33 -0400 Subject: [PATCH] Change default character set from UTF8 to UTF8MB4 In order to allow emojis and other extended character sets, database tables need to be updated to use UTF8MB4, which seems to work well within the phpList app proper. The API using UTF8 encoding prevents extended characters from being stored in the database tables. As I believe UTF8MB4 is a superset of UTF8, this change does not impact installations using UTF8, but does allow those with UTF8MB4 access to the full set of allowed characters. --- plugins/restapi/includes/pdo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/restapi/includes/pdo.php b/plugins/restapi/includes/pdo.php index 3822f83..32fea8f 100644 --- a/plugins/restapi/includes/pdo.php +++ b/plugins/restapi/includes/pdo.php @@ -15,7 +15,7 @@ public static function getConnection() $dbuser = $GLOBALS['database_user']; $dbpass = $GLOBALS['database_password']; $dbname = $GLOBALS['database_name']; - $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname;charset=UTF8;", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8';")); + $dbh = new \PDO("mysql:host=$dbhost;dbname=$dbname;charset=UTF8MB4;", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4';")); $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); return $dbh;