Fatal error in webform list when search text contains accent

Created on 5 February 2025, 2 months ago

Problem/Motivation

When my webmaster used accents (like é ou è in french), we got a fatal 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] => user.role.marché ) in Drupal\Core\Config\DatabaseStorage->readMultiple() (line 111 of core/lib/Drupal/Core/Config/DatabaseStorage.php).

I've a pretty standard database encoding (utf8mb4_general_ci) and accents works well with other features like drupal native search index.

Steps to reproduce

Have a form to search with an accent, like me: "Marchés publics : votre avis nous intéresse"
Use the following route: /admin/structure/webform
Type "marché" in the filter textfield and press enter to submit the form search

Proposed resolution

In webform 6.2.9, modules/contrib/webform/src/WebformEntityListBuilder.php:578
We have:

elseif ($role = $this->getEntityStorage('user_role')->load($keys)) {

this is this line that breaks the script, drupal doesnt like accent on load.
Maybe remove accents before launch the query in this section.

I tried to add modules/contrib/webform/src/WebformEntityListBuilder.php:564 just after if($keys) :

 $keys =     iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $keys);
      // Supprime les résidus non désirés
      $keys = preg_replace('/[^a-zA-Z0-9_ -]/', '', $keys);

Et it works perfectly.

Notes :

- when I entered "marché" , drupal launchs autocomplete, there is no issues:
https://ibb.co/hFMF2Y5S
- I tried to use "marche" in search form instead without accents, it works

🐛 Bug report
Status

Active

Version

6.2

Component

Code

Created by

🇫🇷France tichris59

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

Comments & Activities

Production build 0.71.5 2024