Merge pull request #4491 from Icinga/fix/mysql-charset-usage-on-postgres-dbs-4490
If enforcing a charset, DO IT ONLY IF THE DB TYPE IS CORRECT
This commit is contained in:
commit
022c7da404
|
@ -224,7 +224,7 @@ class UserBackend implements ConfigAwareFactory
|
|||
}
|
||||
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource);
|
||||
if ($backendType === 'db') {
|
||||
if ($backendType === 'db' && $resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ class UserGroupBackend
|
|||
}
|
||||
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($backendConfig->resource);
|
||||
if ($backendType === 'db') {
|
||||
if ($backendType === 'db' && $resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ trait Database
|
|||
$config = new SqlConfig(ResourceFactory::getResourceConfig(
|
||||
IcingaConfig::app()->get('global', 'config_resource')
|
||||
));
|
||||
$config->charset = 'utf8mb4';
|
||||
if ($config->db === 'mysql') {
|
||||
$config->charset = 'utf8mb4';
|
||||
}
|
||||
|
||||
$config->options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ];
|
||||
if ($config->db === 'mysql') {
|
||||
|
|
|
@ -131,7 +131,9 @@ abstract class PreferencesStore
|
|||
$config->location = Config::resolvePath('preferences');
|
||||
} elseif ($type === 'Db') {
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($config->resource);
|
||||
$resourceConfig->charset = 'utf8';
|
||||
if ($resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
$config->connection = ResourceFactory::createResource($resourceConfig);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ class PreferencesCommand extends Command
|
|||
}
|
||||
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($resource);
|
||||
$resourceConfig->charset = 'utf8';
|
||||
if ($resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
$connection = ResourceFactory::createResource($resourceConfig);
|
||||
|
||||
$preferencesPath = Config::resolvePath('preferences');
|
||||
|
|
|
@ -207,7 +207,9 @@ class UserDomainMigration
|
|||
break;
|
||||
case 'db':
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($config->get('global', 'config_resource'));
|
||||
$resourceConfig->charset = 'utf8';
|
||||
if ($resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
/** @var DbConnection $conn */
|
||||
$conn = ResourceFactory::createResource($resourceConfig);
|
||||
|
@ -292,7 +294,9 @@ class UserDomainMigration
|
|||
}
|
||||
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($config->resource);
|
||||
$resourceConfig->charset = 'utf8';
|
||||
if ($resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
/** @var DbConnection $conn */
|
||||
$conn = ResourceFactory::createResource($resourceConfig);
|
||||
|
@ -343,7 +347,9 @@ class UserDomainMigration
|
|||
}
|
||||
|
||||
$resourceConfig = ResourceFactory::getResourceConfig($config->resource);
|
||||
$resourceConfig->charset = 'utf8';
|
||||
if ($resourceConfig->db === 'mysql') {
|
||||
$resourceConfig->charset = 'utf8';
|
||||
}
|
||||
|
||||
/** @var DbConnection $conn */
|
||||
$conn = ResourceFactory::createResource($resourceConfig);
|
||||
|
|
Loading…
Reference in New Issue