Problem/Motivation
(Why the issue was filed, steps to reproduce the problem, etc.)
Steps to reproduce
- Install Standard profile (check that 'contact' module is enabled)
- Go to
/contact/Perú. "Perú" can be any text not in english alphabet (Greek, Spanish, German special characters) - 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'
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3188740-3.patch | 1019 bytes | Pooja Ganjage |
Issue fork drupal-3188740
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
Comment #2
prabha.venkatesan commentedComment #3
Pooja Ganjage commentedHi,
Creating a patch for this issue.
Please review the patch.
Thanks.
Comment #4
Pooja Ganjage commentedComment #5
prabha.venkatesan commentedThis patch is working fine. Thanks :)
Comment #7
mxr576We 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.
Comment #10
smustgrave commentedThis 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.
Comment #13
dimitriskr commentedI'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
Comment #15
dimitriskr commentedComment #16
dimitriskr commentedComment #17
dimitriskr commentedFailing test
Comment #18
simohell commentedSame 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.
Comment #19
simohell commentedAlso 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.
Comment #21
dimitriskr commentedIt seems a similar issue was fixed on webform