Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly set charset and collation for Drupal sites #33

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

tobybellwood
Copy link
Member

@tobybellwood tobybellwood commented Aug 22, 2024

Currently, Drupal only specifies a default charset to use (utfmb4) - this means that the table collation is chosen by the server default for utf8mb4 (not the database default) - as per https://dev.mysql.com/doc/refman/8.0/en/charset-table.html

This PR sets a sensible default charset and collation that should suit most uses, and be compatible with mariadb and MySQL installs. If your site requires additional configuration in the charset or collation, the entire paragraph should be replicated into your git config, and updated in the /assets/all.settings.php file

Note that this will not tables in an existing install, but will apply to new tables created (either a fresh install or an updb)

e.g to use the esperanto-specific collation:

if (getenv('LAGOON')) {
  $databases['default']['default'] = [
    'driver' => 'mysql',
    'database' => getenv('MARIADB_DATABASE') ?: 'drupal',
    'username' => getenv('MARIADB_USERNAME') ?: 'drupal',
    'password' => getenv('MARIADB_PASSWORD') ?: 'drupal',
    'host' => getenv('MARIADB_HOST') ?: 'mariadb',
    'port' => getenv('MARIADB_PORT') ?: 3306,
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_esperanto_ci',
    'prefix' => '',
  ];
}

@tobybellwood tobybellwood merged commit 5ff908d into main Sep 4, 2024
2 checks passed
@tobybellwood tobybellwood deleted the charset-collations branch September 4, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants