Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit fe37e57

Browse files
committed
Use default GLPI charset/collation during install/update
1 parent 32c3b0e commit fe37e57

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

inc/config.class.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ static function install(Migration $migration) {
239239
$table = getTableForItemType(__CLASS__);
240240

241241
if (!$DB->tableExists($table)) {
242+
$default_charset = DBConnection::getDefaultCharset();
243+
$default_collation = DBConnection::getDefaultCollation();
244+
242245
$query = "CREATE TABLE `".$table."` (
243246
`id` int NOT NULL AUTO_INCREMENT,
244247
`host` varchar(255) NOT NULL default '',
@@ -260,7 +263,7 @@ static function install(Migration $migration) {
260263
`use_proxy` int NOT NULL DEFAULT 0,
261264
`is_password_sodium_encrypted` int NOT NULL DEFAULT 1,
262265
PRIMARY KEY (`id`)
263-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
266+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};";
264267
$DB->query($query) or die($DB->error());
265268

266269
$query = "INSERT INTO `$table` (id) VALUES (1)";

inc/mantis.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ static function install(Migration $migration) {
102102
$table = getTableForItemType(__CLASS__);
103103

104104
if (!$DB->tableExists($table)) {
105+
$default_charset = DBConnection::getDefaultCharset();
106+
$default_collation = DBConnection::getDefaultCollation();
105107

106108
$query = "CREATE TABLE `".$table."` (
107109
`id` int NOT NULL AUTO_INCREMENT,
@@ -111,7 +113,7 @@ static function install(Migration $migration) {
111113
`itemtype` varchar(255) NOT NULL,
112114
`user` int NOT NULL,
113115
PRIMARY KEY (`id`)
114-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
116+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};";
115117
$DB->query($query) or die($DB->error());
116118

117119
} else {

0 commit comments

Comments
 (0)