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

Commit be40865

Browse files
committed
Use default GLPI charset/collation during install/update
1 parent aa39ace commit be40865

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
@@ -244,6 +244,9 @@ static function install(Migration $migration) {
244244
$table = getTableForItemType(__CLASS__);
245245

246246
if (!$DB->tableExists($table)) {
247+
$default_charset = DBConnection::getDefaultCharset();
248+
$default_collation = DBConnection::getDefaultCollation();
249+
247250
$query = "CREATE TABLE `".$table."` (
248251
`id` int NOT NULL AUTO_INCREMENT,
249252
`host` varchar(255) NOT NULL default '',
@@ -265,7 +268,7 @@ static function install(Migration $migration) {
265268
`use_proxy` int NOT NULL DEFAULT 0,
266269
`is_password_sodium_encrypted` int NOT NULL DEFAULT 1,
267270
PRIMARY KEY (`id`)
268-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
271+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};";
269272
$DB->query($query) or die($DB->error());
270273

271274
$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
@@ -107,6 +107,8 @@ static function install(Migration $migration) {
107107
$table = getTableForItemType(__CLASS__);
108108

109109
if (!$DB->tableExists($table)) {
110+
$default_charset = DBConnection::getDefaultCharset();
111+
$default_collation = DBConnection::getDefaultCollation();
110112

111113
$query = "CREATE TABLE `".$table."` (
112114
`id` int NOT NULL AUTO_INCREMENT,
@@ -116,7 +118,7 @@ static function install(Migration $migration) {
116118
`itemtype` varchar(255) NOT NULL,
117119
`user` int NOT NULL,
118120
PRIMARY KEY (`id`)
119-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
121+
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation};";
120122
$DB->query($query) or die($DB->error());
121123

122124
} else {

0 commit comments

Comments
 (0)