Skip to content

Commit

Permalink
Don't use utf8mb4 if collation is set to utf8_*
Browse files Browse the repository at this point in the history
Fixes #14332
  • Loading branch information
brandonkelly committed Mar 29, 2024
1 parent 3866c79 commit 79ba861
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Fixed a bug where “Admin” rules were available to user conditions in Solo and Team editions.
- Fixed a bug where entries’ “View in a new tab” breadcrumb actions were linking to the canonical entry URL when editing a draft or viewing a revision. ([#14705](https://github.com/craftcms/cms/issues/14705))
- Fixed a bug where Matrix blocks without labels had extra spacing above them in Live Preview. ([#14703](https://github.com/craftcms/cms/issues/14703))
- Fixed an error that occurred if the `collation` database connection setting was set to `utf8_*` on MySQL. ([#14332](https://github.com/craftcms/cms/issues/14332))

## 5.0.0 - 2024-03-26

Expand Down
6 changes: 5 additions & 1 deletion src/config/DbConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ public function charset(string $value): self
*/
public function getCharset(): string
{
if ($this->charset === 'utf8' && $this->driver === Connection::DRIVER_MYSQL) {
if (
$this->driver === Connection::DRIVER_MYSQL &&
$this->charset === 'utf8' &&
(!isset($this->collation) || str_starts_with($this->collation, 'utf8mb4_'))
) {
// treat utf8 as an alias for utf8mb4
// (MySQL aliases it to utf8mb3, but that's deprecated and likely to change eventually)
return 'utf8mb4';
Expand Down

0 comments on commit 79ba861

Please sign in to comment.