Skip to content

Commit

Permalink
make encoding required
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Feb 16, 2024
1 parent dafe312 commit 8c3b699
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 2 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/Jackalope/Transport/DoctrineDBAL/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 8c3b699

Please sign in to comment.