Problem/Motivation

(Why the issue was filed, steps to reproduce the problem, etc.)

Steps to reproduce

  1. Install Standard profile (check that 'contact' module is enabled)
  2. Go to /contact/Perú. "Perú" can be any text not in english alphabet (Greek, Spanish, German special characters)
  3. Get the following error

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=': SELECT "name", "data" FROM "config" WHERE "collection" = :collection AND "name" IN ( :names__0 ); Array ( [:collection] => [:names__0] => contact.form.Perú ) in Drupal\Core\Config\DatabaseStorage->readMultiple() (line 111 of web/core/lib/Drupal/Core/Config/DatabaseStorage.php).

Proposed resolution

TBD

Remaining tasks

Find a fix, write a more comprehensive test

User interface changes

TBD

Introduced terminology

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Original report by prabha.venkatesan

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=': SELECT name, value FROM {key_value_expire} WHERE expire > :now AND name IN ( :keys__0 ) AND collection = :collection; Array ( [:now] => 1608110913 [:collection] => form [:keys__0] => NS09<s1﹥DBLʺSNGLʹNS09 ) in Drupal\Core\KeyValueStore\StorageBase->get() (line 35 of /var/www/html/core/lib/Drupal/Core/KeyValueStore/StorageBase.php).

This issue occurs when we modify the POST request data to a form and insert some utf-8 character in form_build_id.
ParameterName: form_build_id
ParameterType: POST
Payload: NS09<s1﹥DBLʺSNGLʹNS09
But the database uses 'utf8mb4_general_ci' collation and also all the tables in the database also has 'utf8mb4_general_ci' collation.
I could not find any table using the collation 'ascii_general_ci'

CommentFileSizeAuthor
#3 3188740-3.patch1019 bytesPooja Ganjage

Issue fork drupal-3188740

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prabha.venkatesan created an issue. See original summary.

prabha.venkatesan’s picture

Issue summary: View changes
Pooja Ganjage’s picture

StatusFileSize
new1019 bytes

Hi,

Creating a patch for this issue.

Please review the patch.

Thanks.

Pooja Ganjage’s picture

Status: Active » Needs review
prabha.venkatesan’s picture

This patch is working fine. Thanks :)

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mxr576’s picture

Version: 9.2.x-dev » 9.4.x-dev
Issue tags: +Security

We identified some malicious attempts on some sites that we maintain and while attackers tried to leverage DrupalGeddon 2 they also tried to manipulate the form_id which lead to this db level error.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Category: Task » Bug report
Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests, +Needs issue summary update

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Appears to be a bug which will require a test case/coverage

Also the proposed solution should be added to the issue summary, recommend using default template.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

prudloff made their first commit to this issue’s fork.

dimitriskr’s picture

I'm also getting a similar error, but on a different occasion, for example when a (malicious) request goes to /contact/Perú
I'll try to reproduce it on a clean install and upload a failing test

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=': SELECT "name", "data" FROM "config" WHERE "collection" = :collection AND "name" IN ( :names__0 ); Array ( [:collection] => [:names__0] => contact.form.Perú ) in Drupal\Core\Config\DatabaseStorage->readMultiple() (line 111 of web/core/lib/Drupal/Core/Config/DatabaseStorage.php).

dimitriskr’s picture

Issue summary: View changes
Issue tags: -Needs tests, -Needs issue summary update
dimitriskr’s picture

Issue summary: View changes
dimitriskr’s picture

simohell’s picture

Priority: Normal » Major

Same error appears with menus:

/fi/admin/structure/menu/manage/p%C3%A4%C3%A4valikko
(for the example päävalikko = main menu in Finnish)

The website encountered an unexpected error. Try again later.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_swedish_ci,COERCIBLE) for operation '=': SELECT "name", "data" FROM "config" WHERE "collection" = :collection AND "name" IN ( :names__0 ); Array ( [:collection] => [:names__0] => system.menu.päävalikko ) in Drupal\Core\Config\DatabaseStorage->readMultiple() (line 115 of core/lib/Drupal/Core/Config/DatabaseStorage.php).

This bug affects unknown number of paths in admin UI and results in WSOD so I would recommend upgrading the priority.

There is also an ongoing investigation whether or not this (in connection with some contrib modules and caches) caused a system failure on a production frontend that is accessing Drupal via JSON:API.

simohell’s picture

Issue tags: +Usability

Also tagging this for usability bug. The behaviour breaks one of 10 general principles of user interface design: "9: Help Users Recognize, Diagnose, and Recover from Errors". Basically this means that we should never give out a WSOD (with PHP/SQL error depending on the settings) if we have sensible alternatives.

The obvious correct behaviour is displaying the same 404 page than with other bad routes that consist only of ascii characters.

A recurring user action that will trigger this is a URL copy-paste action with a user error (including extra characters). The error may have entered URL to a site's documentation making the error repetitive.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

dimitriskr’s picture

It seems a similar issue was fixed on webform