diff --git a/CHANGELOG.md b/CHANGELOG.md index ca25aae1..de5bece8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,8 @@ Changelog When instantiating the client, you need to provide at least the cache instance for metadata, as CachedClient does not know which implementation to pick. * Support for new Symfony versions. * Support for doctrine/dbal 4. -* For MySQL/MariaDB, default to `utf8mb4` encoding instead of `utf8` if autodiscovery does not provide the encoding. - If you get errors about the collation, either upgrade your database to utf8mb4 or explicitly configure the encoding - with `Client::setCaseSensitiveEncoding('utf8_bin')`. The error on misconfiguration looks like this: - - 1253 COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4' - +* For MySQL/MariaDB, it is now required to configure `collate` or `charset` in the Doctrine connection, or alternatively + set the encoding explicitly with `Client::setCaseSensitiveEncoding('utf8_bin')`. * If you are on PHP 8.0 and install Jackalope with `symfony/cache`, you need to restrict `psr/simple-cache` to `^1.0 || ^2.0` in your application because Symfony 5 does not declare a conflict with it, but fails at runtime. * Drop support for PHP 7. * Fixed: While it is allowed to call `Repository::login` with `null` credentials, there used to be an error. It now correctly works. diff --git a/src/Jackalope/Transport/DoctrineDBAL/Client.php b/src/Jackalope/Transport/DoctrineDBAL/Client.php index 860f6854..cd3c55a6 100644 --- a/src/Jackalope/Transport/DoctrineDBAL/Client.php +++ b/src/Jackalope/Transport/DoctrineDBAL/Client.php @@ -385,6 +385,9 @@ private function getMySQLCaseSensitiveEncoding(): string if (isset($params['defaultTableOptions']['collate'])) { return $this->caseSensitiveEncoding = $params['defaultTableOptions']['collate']; } + if (!array_key_exists('charset', $params)) { + 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'; return $this->caseSensitiveEncoding = 'binary' === $charset ? $charset : $charset.'_bin';