From 120c860dbe197b5bf87137d0868a9a2e9b5ed4a5 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Apr 2024 06:33:56 +0200 Subject: [PATCH] improve missing charset parameter handling --- src/Jackalope/Transport/DoctrineDBAL/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Jackalope/Transport/DoctrineDBAL/Client.php b/src/Jackalope/Transport/DoctrineDBAL/Client.php index 9bdebaa9..3d817b2f 100644 --- a/src/Jackalope/Transport/DoctrineDBAL/Client.php +++ b/src/Jackalope/Transport/DoctrineDBAL/Client.php @@ -385,10 +385,10 @@ private function getMySQLCaseSensitiveEncoding(): string if (isset($params['defaultTableOptions']['collate'])) { return $this->caseSensitiveEncoding = $params['defaultTableOptions']['collate']; } - if (!array_key_exists('charset', $params)) { + if (!array_key_exists('charset', $params) || !$params['charset']) { throw new \InvalidArgumentException('For MySQL, the Doctrine dbal connection must have either "collate" or "charset" configured. Alternatively, you can set the encoding with '.__CLASS__.'::setCaseSensitiveEncoding().'); } - $charset = $params['charset'] ?? 'utf8'; + $charset = $params['charset']; return $this->caseSensitiveEncoding = 'binary' === $charset ? $charset : $charset.'_bin'; }