Merge pull request #4484 from Icinga/fix/enforce-charset-on-internal-db-queries-4446
Enforce charset on internal db queries
This commit is contained in:
commit
88f2c50f0b
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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') {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue