From 9a29d8f3d4fc7e5c50a77316a2c0896f3f5edf65 Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Fri, 3 Apr 2020 11:40:46 +0200 Subject: [PATCH] Set default db charset for MySQL ido resources to latin1 latin1 seems to be the only supported charset for MySQL but the current upstream default charset is utf8mb4 and to be safe it should be set explicitly --- .../library/Monitoring/Backend/MonitoringBackend.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index 31e6488a7..164687623 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -222,7 +222,11 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface public function getResource() { if ($this->resource === null) { - $this->resource = ResourceFactory::create($this->config->get('resource')); + $config = ResourceFactory::getResourceConfig($this->config->get('resource')); + if ($this->is('ido') && $config->type === 'db' && $config->db === 'mysql' && $config->charset === null) { + $config->charset = 'latin1'; + } + $this->resource = ResourceFactory::createResource($config); if ($this->is('ido') && $this->resource->getDbType() !== 'oracle') { // TODO(el): The resource should set the table prefix $this->resource->setTablePrefix('icinga_');