From 99bf28fef1a5bb0f89919d1e5e722c9eace6826a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 28 Oct 2017 20:36:59 +0200 Subject: mysql: Enable full UTF8 support Signed-off-by: Florian Pritz --- NEWS | 3 +++ application/config/example/database.php | 6 +++--- application/config/migration.php | 2 +- application/migrations/021_change_charset.php | 27 +++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 application/migrations/021_change_charset.php diff --git a/NEWS b/NEWS index 1b50055e7..fe86bcda5 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ This file lists major, incompatible or otherwise important changes, you should l - Changes in application/config/database.php + Change "$active_record = TRUE" to "$query_builder = TRUE" + Change the pconnect setting to FALSE + + Change the char_set settign to "utf8mb4" + + Change the dbcollat setting to "utf8mb4_bin" + + Change the stricton setting to TRUE - Changes in application/config/config-local.php + Set base_url to your domain and installation directory (if used). Example: $config['base_url'] = "https://paste.xinu.at/" diff --git a/application/config/example/database.php b/application/config/example/database.php index b4cb64039..6b71bf60b 100644 --- a/application/config/example/database.php +++ b/application/config/example/database.php @@ -86,12 +86,12 @@ $db['default'] = array( 'db_debug' => TRUE, 'cache_on' => FALSE, 'cachedir' => '', - 'char_set' => 'utf8', - 'dbcollat' => 'utf8_general_ci', + 'char_set' => 'utf8mb4', + 'dbcollat' => 'utf8mb4_bin', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, - 'stricton' => FALSE, + 'stricton' => TRUE, 'failover' => array(), 'save_queries' => TRUE ); diff --git a/application/config/migration.php b/application/config/migration.php index 621a0eeb6..ffddae2ac 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -69,7 +69,7 @@ $config['migration_auto_latest'] = FALSE; | be upgraded / downgraded to. | */ -$config['migration_version'] = 20; +$config['migration_version'] = 21; /* |-------------------------------------------------------------------------- diff --git a/application/migrations/021_change_charset.php b/application/migrations/021_change_charset.php new file mode 100644 index 000000000..20a8ce7f7 --- /dev/null +++ b/application/migrations/021_change_charset.php @@ -0,0 +1,27 @@ +db->dbprefix; + + if ($this->db->dbdriver == 'postgre') { + # nothing to do + } else { + $this->db->query('SET FOREIGN_KEY_CHECKS = 0'); + foreach (['actions', 'apikeys', 'files', 'file_storage', 'multipaste', 'multipaste_file_map', 'profiles', 'users'] as $table) { + $this->db->query(' + ALTER TABLE `'.$prefix.$table.'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; + '); + } + $this->db->query('SET FOREIGN_KEY_CHECKS = 1'); + } + } + + public function down() + { + throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported"); + } +} -- cgit v1.2.3-24-g4f1b