diff --git a/library/Icinga/Authentication/User/UserBackend.php b/library/Icinga/Authentication/User/UserBackend.php index 954356819..13e688795 100644 --- a/library/Icinga/Authentication/User/UserBackend.php +++ b/library/Icinga/Authentication/User/UserBackend.php @@ -223,7 +223,12 @@ class UserBackend implements ConfigAwareFactory ); } - $resource = ResourceFactory::create($backendConfig->resource); + $resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource); + if ($backendType === 'db') { + $resourceConfig->charset = 'utf8'; + } + + $resource = ResourceFactory::createResource($resourceConfig); switch ($backendType) { case 'db': $backend = new DbUserBackend($resource); diff --git a/library/Icinga/Authentication/UserGroup/UserGroupBackend.php b/library/Icinga/Authentication/UserGroup/UserGroupBackend.php index 6513002f5..2a5948823 100644 --- a/library/Icinga/Authentication/UserGroup/UserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/UserGroupBackend.php @@ -164,8 +164,13 @@ class UserGroupBackend $name ); } - $resource = ResourceFactory::create($backendConfig->resource); + $resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource); + if ($backendType === 'db') { + $resourceConfig->charset = 'utf8'; + } + + $resource = ResourceFactory::createResource($resourceConfig); switch ($backendType) { case 'db': $backend = new DbUserGroupBackend($resource); diff --git a/library/Icinga/Common/Database.php b/library/Icinga/Common/Database.php index 32d21153f..fbe1e0260 100644 --- a/library/Icinga/Common/Database.php +++ b/library/Icinga/Common/Database.php @@ -31,6 +31,7 @@ trait Database $config = new SqlConfig(ResourceFactory::getResourceConfig( IcingaConfig::app()->get('global', 'config_resource') )); + $config->charset = 'utf8mb4'; $config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ]; if ($config->db === 'mysql') { diff --git a/library/Icinga/User/Preferences/PreferencesStore.php b/library/Icinga/User/Preferences/PreferencesStore.php index c88cf332d..b6d63a9ad 100644 --- a/library/Icinga/User/Preferences/PreferencesStore.php +++ b/library/Icinga/User/Preferences/PreferencesStore.php @@ -130,7 +130,10 @@ abstract class PreferencesStore Logger::warning('The preferences backend of type INI is deprecated and will be removed with version 2.11'); $config->location = Config::resolvePath('preferences'); } elseif ($type === 'Db') { - $config->connection = new DbConnection(ResourceFactory::getResourceConfig($config->resource)); + $resourceConfig = ResourceFactory::getResourceConfig($config->resource); + $resourceConfig->charset = 'utf8'; + + $config->connection = ResourceFactory::createResource($resourceConfig); } return new $storeClass($config, $user); diff --git a/modules/migrate/application/clicommands/PreferencesCommand.php b/modules/migrate/application/clicommands/PreferencesCommand.php index 65f2b43da..fa2bad50c 100644 --- a/modules/migrate/application/clicommands/PreferencesCommand.php +++ b/modules/migrate/application/clicommands/PreferencesCommand.php @@ -35,7 +35,9 @@ class PreferencesCommand extends Command $resource = $this->params->getRequired('resource'); } - $connection = ResourceFactory::create($resource); + $resourceConfig = ResourceFactory::getResourceConfig($resource); + $resourceConfig->charset = 'utf8'; + $connection = ResourceFactory::createResource($resourceConfig); $preferencesPath = Config::resolvePath('preferences'); if (! file_exists($preferencesPath)) { diff --git a/modules/migrate/library/Migrate/Config/UserDomainMigration.php b/modules/migrate/library/Migrate/Config/UserDomainMigration.php index d56722b4e..5edc93722 100644 --- a/modules/migrate/library/Migrate/Config/UserDomainMigration.php +++ b/modules/migrate/library/Migrate/Config/UserDomainMigration.php @@ -206,8 +206,11 @@ class UserDomainMigration break; case 'db': + $resourceConfig = ResourceFactory::getResourceConfig($config->get('global', 'config_resource')); + $resourceConfig->charset = 'utf8'; + /** @var DbConnection $conn */ - $conn = ResourceFactory::create($config->get('global', 'config_resource')); + $conn = ResourceFactory::createResource($resourceConfig); $query = $conn ->select() @@ -288,8 +291,11 @@ class UserDomainMigration continue; } + $resourceConfig = ResourceFactory::getResourceConfig($config->resource); + $resourceConfig->charset = 'utf8'; + /** @var DbConnection $conn */ - $conn = ResourceFactory::create($config->resource); + $conn = ResourceFactory::createResource($resourceConfig); $query = $conn ->select() @@ -336,8 +342,11 @@ class UserDomainMigration continue; } + $resourceConfig = ResourceFactory::getResourceConfig($config->resource); + $resourceConfig->charset = 'utf8'; + /** @var DbConnection $conn */ - $conn = ResourceFactory::create($config->resource); + $conn = ResourceFactory::createResource($resourceConfig); $query = $conn ->select()