Skip to content

Commit 5c3a4ba

Browse files
bramleymichield
andauthored
Use utf8mb4 for the connection etc (#1001)
* Use utf8mb4 for the connection etc * Support utf8mb4 in campaign subject and content --------- Co-authored-by: Michiel Dethmers <[email protected]>
1 parent 5b12686 commit 5c3a4ba

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

public_html/lists/admin/mysqli.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function Sql_Connect($host, $user, $password, $database)
7777
print "Cannot connect to Database, please check your configuration";
7878
exit;
7979
}
80-
mysqli_query($db, "SET NAMES 'utf8'");
80+
mysqli_query($db, "SET NAMES 'utf8mb4'");
8181
unset($GLOBALS['lastquery']);
8282

8383
return $db;

public_html/lists/admin/structure.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@
118118
'message' => array( // a message
119119
'id' => array('integer not null primary key auto_increment', 'ID'),
120120
'uuid' => array('varchar(36) default ""', 'UUID'),
121-
'subject' => array("varchar(255) not null default '(no subject)'", 'subject'),
121+
'subject' => array("varchar(255) character set utf8mb4 not null default '(no subject)'", 'subject'),
122122
'fromfield' => array("varchar(255) not null default ''", 'from'),
123123
'tofield' => array("varchar(255) not null default ''", 'tofield'),
124124
'replyto' => array("varchar(255) not null default ''", 'reply-to'),
125-
'message' => array('longtext', 'Message'),
126-
'textmessage' => array('longtext', 'Text version of Message'),
125+
'message' => array('longtext character set utf8mb4', 'Message'),
126+
'textmessage' => array('longtext character set utf8mb4', 'Text version of Message'),
127127
'footer' => array('text', 'Footer for a message'),
128128
'entered' => array('datetime', 'Entered'),
129129
'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
@@ -155,7 +155,7 @@
155155
'messagedata' => array(
156156
'name' => array('varchar(100) not null', 'Name of field'),
157157
'id' => array('integer not null', 'Message ID'),
158-
'data' => array('longtext', 'Data'),
158+
'data' => array('longtext character set utf8mb4', 'Data'),
159159
'primary key' => array('(name,id)', ''),
160160
),
161161
'listmessage' => array( // linking messages to a list

public_html/lists/admin/upgrade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,13 @@ function output($message)
326326
Sql_Query("alter table {$GLOBALS['tables']['admin']} modify modifiedby varchar(66) default ''");
327327
}
328328

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

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

0 commit comments

Comments
 (0)