Skip to content

Commit

Permalink
Use utf8mb4 for the connection etc (#1001)
Browse files Browse the repository at this point in the history
* Use utf8mb4 for the connection etc

* Support utf8mb4 in campaign subject and content

---------

Co-authored-by: Michiel Dethmers <michiel@phplist.com>
  • Loading branch information
bramley and michield committed Apr 6, 2024
1 parent 5b12686 commit 5c3a4ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion public_html/lists/admin/mysqli.inc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Sql_Connect($host, $user, $password, $database)
print "Cannot connect to Database, please check your configuration";
exit;
}
mysqli_query($db, "SET NAMES 'utf8'");
mysqli_query($db, "SET NAMES 'utf8mb4'");
unset($GLOBALS['lastquery']);

return $db;
Expand Down
8 changes: 4 additions & 4 deletions public_html/lists/admin/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@
'message' => array( // a message
'id' => array('integer not null primary key auto_increment', 'ID'),
'uuid' => array('varchar(36) default ""', 'UUID'),
'subject' => array("varchar(255) not null default '(no subject)'", 'subject'),
'subject' => array("varchar(255) character set utf8mb4 not null default '(no subject)'", 'subject'),
'fromfield' => array("varchar(255) not null default ''", 'from'),
'tofield' => array("varchar(255) not null default ''", 'tofield'),
'replyto' => array("varchar(255) not null default ''", 'reply-to'),
'message' => array('longtext', 'Message'),
'textmessage' => array('longtext', 'Text version of Message'),
'message' => array('longtext character set utf8mb4', 'Message'),
'textmessage' => array('longtext character set utf8mb4', 'Text version of Message'),
'footer' => array('text', 'Footer for a message'),
'entered' => array('datetime', 'Entered'),
'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
Expand Down Expand Up @@ -155,7 +155,7 @@
'messagedata' => array(
'name' => array('varchar(100) not null', 'Name of field'),
'id' => array('integer not null', 'Message ID'),
'data' => array('longtext', 'Data'),
'data' => array('longtext character set utf8mb4', 'Data'),
'primary key' => array('(name,id)', ''),
),
'listmessage' => array( // linking messages to a list
Expand Down
7 changes: 7 additions & 0 deletions public_html/lists/admin/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ function output($message)
Sql_Query("alter table {$GLOBALS['tables']['admin']} modify modifiedby varchar(66) default ''");
}

if (version_compare($dbversion, '3.6.15','<')) {
// support utf8mb4 for campaign subject and content
Sql_Query("alter table {$GLOBALS['tables']['message']} modify subject varchar(255) character set utf8mb4 not null default '(no subject)'");
Sql_Query("alter table {$GLOBALS['tables']['message']} modify message longtext character set utf8mb4");
Sql_Query("alter table {$GLOBALS['tables']['message']} modify textmessage longtext character set utf8mb4");
Sql_Query("alter table {$GLOBALS['tables']['messagedata']} modify data longtext character set utf8mb4");
}

if (!Sql_Table_exists($GLOBALS['tables']['admin_login'])) {
cl_output(s('Creating new table "admin_login"'));
Expand Down

0 comments on commit 5c3a4ba

Please sign in to comment.