Changed mysql collaction to utf8mb4_unicode_ci
authorMarcel Werk <burntime@woltlab.com>
Fri, 22 Jul 2016 21:44:34 +0000 (23:44 +0200)
committerMarcel Werk <burntime@woltlab.com>
Fri, 22 Jul 2016 21:44:34 +0000 (23:44 +0200)
wcfsetup/install/files/lib/system/database/MySQLDatabase.class.php
wcfsetup/install/files/lib/system/database/editor/MySQLDatabaseEditor.class.php
wcfsetup/install/files/lib/system/option/user/UserOptionHandler.class.php
wcfsetup/install/files/lib/util/MessageUtil.class.php

index a112f073d6009eddf3ecfa2d18d9a6fdccc1114b..82c7fa53e2c1c27e610c7b996369c90456869955 100644 (file)
@@ -25,11 +25,11 @@ class MySQLDatabase extends Database {
                
                try {
                        $driverOptions = [
-                               \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
+                               \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
                        ];
                        if (!$this->failsafeTest) {
                                $driverOptions = [
-                                       \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
+                                       \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4', SESSION sql_mode = 'ANSI,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"
                                ];
                        }
                        
index d32e9aa13ccee9a364468880ec308596d825d59b..04e331331f947203b783fbb00d83efe84aab1658 100644 (file)
@@ -92,7 +92,7 @@ class MySQLDatabaseEditor extends DatabaseEditor {
                                ".$columnDefinition."
                                ".(!empty($indexDefinition) ? ',' : '')."
                                ".$indexDefinition."
-                       ) ENGINE=".($hasFulltextIndex ? 'MyISAM' : 'InnoDB')." DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
+                       ) ENGINE=".($hasFulltextIndex ? 'MyISAM' : 'InnoDB')." DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
                $statement = $this->dbObj->prepareStatement($sql);
                $statement->execute();
        }
index f8aef0b8132640ba8fabd4afd5a77938db561dfb..908d176304041e4d77bd3eb21a536298484f2aa7 100644 (file)
@@ -292,7 +292,6 @@ class UserOptionHandler extends OptionHandler {
        public function readUserInput(array &$source) {
                parent::readUserInput($source);
                
-               // remove 4 byte utf-8 characters (e.g. emoji)
                foreach ($this->rawValues as &$value) {
                        if (is_string($value)) $value = MessageUtil::stripCrap($value);
                }
index cb1b042f4e77422147ee883daaec9ba5e6cd5fba..dac872fcb5ccbcb6bc546ad1ddecd308a73c81bf 100644 (file)
@@ -31,10 +31,6 @@ class MessageUtil {
                // unify new lines
                $text = StringUtil::unifyNewlines($text);
                
-               // remove 4 byte utf-8 characters as MySQL < 5.5 does not support them
-               // see http://stackoverflow.com/a/16902461/782822
-               $text = preg_replace('/[\xF0-\xF7].../s', '', $text);
-               
                // remove control characters
                $text = preg_replace('~[\x00-\x08\x0B-\x1F\x7F]~', '', $text);