Unable to delete a tempstore when a non ASCII character is used.

Created on 16 July 2021, over 3 years ago
Updated 14 March 2023, over 1 year ago

Problem/Motivation

When attempting to delete a tempstore with a non ASCII character such as en or em dash the following error is thrown.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=': DELETE FROM {key_value_expire} WHERE ("name" IN (:db_condition_placeholder_0)) AND ("collection" = :db_condition_placeholder_1); Array ( [:db_condition_placeholder_0] => 2020β€”2021 [:db_condition_placeholder_1] => tempstore.shared.my_module_name ) in Drupal\Core\KeyValueStore\StorageBase->delete() (line 52 of core/lib/Drupal/Core/KeyValueStore/StorageBase.php).

Steps to reproduce

Create a custom module then attempt the following:

$keyword = '2020–2021';
$tempstore = \Drupal::service('tempstore.shared')->get('my_module_name');
$tempstore->delete($keyword);

Proposed resolution

Update the way tables are created to allow for the collation specified in settings.php before defaulting to ascii.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

9.5

Component
DatabaseΒ  β†’

Last updated 3 days ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡ΊπŸ‡ΈUnited States blu_regard

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024