-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for utf8mb4 (emoji support) #798
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -67,6 +67,11 @@ function qa_db_table_definitions() | |||||
require_once QA_INCLUDE_DIR . 'db/maxima.php'; | ||||||
require_once QA_INCLUDE_DIR . 'app/users.php'; | ||||||
|
||||||
if (defined('QA_USE_UTF8MB4') && QA_USE_UTF8MB4) | ||||||
$collation = 'utf8mb4_bin'; | ||||||
else | ||||||
$collation = 'utf_bin'; | ||||||
|
||||||
/* | ||||||
Important note on character encoding in database and PHP connection to MySQL | ||||||
|
||||||
|
@@ -107,7 +112,7 @@ function qa_db_table_definitions() | |||||
'avatarheight' => 'SMALLINT UNSIGNED', // pixel height of stored avatar | ||||||
'passsalt' => 'BINARY(16)', // salt used to calculate passcheck - null if no password set for direct login | ||||||
'passcheck' => 'BINARY(20)', // checksum from password and passsalt - null if no password set for direct login | ||||||
'passhash' => 'VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL', // password_hash | ||||||
'passhash' => 'VARCHAR(255) CHARACTER SET utf8 COLLATE '.$collation.' DEFAULT NULL', // password_hash | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to change the charset if you change the collation, apparently... Otherwise you may get an error like:
(At least I got it in MariaDB)
Suggested change
(Of course may be adjusted to work with the defined |
||||||
'level' => 'TINYINT UNSIGNED NOT NULL', // basic, editor, admin, etc... | ||||||
'loggedin' => 'DATETIME NOT NULL', // time of last login | ||||||
'loginip' => 'VARBINARY(16) NOT NULL', // INET6_ATON of IP address of last login | ||||||
|
@@ -714,7 +719,10 @@ function qa_db_create_table_sql($rawname, $definition) | |||||
if (isset($coldef)) | ||||||
$querycols .= (strlen($querycols) ? ', ' : '') . (is_int($colname) ? $coldef : ($colname . ' ' . $coldef)); | ||||||
|
||||||
return 'CREATE TABLE ^' . $rawname . ' (' . $querycols . ') ENGINE=InnoDB CHARSET=utf8'; | ||||||
if (defined('QA_USE_UTF8MB4') && QA_USE_UTF8MB4) | ||||||
return 'CREATE TABLE ^' . $rawname . ' (' . $querycols . ') ENGINE=InnoDB CHARSET=utf8mb4'; | ||||||
else | ||||||
return 'CREATE TABLE ^' . $rawname . ' (' . $querycols . ') ENGINE=InnoDB CHARSET=utf8'; | ||||||
} | ||||||
|
||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this same check is used many times, I'd suggest extracting it into a function e.g.
qa_db_get_mysql_collation()