Problem/Motivation
When importing a csv containing strings in UTF-8 character encoding format an error occurs when launching a query to the database.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '=': SELECT n.tid FROM {taxonomy_term_field_data} n WHERE n.name = :uid AND n.vid = :vid; Array ( [:uid] => Alcal� de Henares [:vid] => municipios_madrid ) en Drupal\taxonomy_import\Form\create_taxonomy() (linea 148 de /var/www/html/web/modules/contrib/taxonomy_import/src/Form/ImportForm.php).
Steps to reproduce
In a database with collation 'utf8_unicode_ci' (use the query "SELECT @@character_set_database, @@collation_database;" to check), import a csv file containing strings with UTF-8 format (such as 'á, é, í, ó, ú, ñ...). When importing the .csv, you will reproduce the exception.
Proposed resolution
Encode the string "$data[0]" to UTF-8 before launching the query to the database.
Remaining tasks
Working on a patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
juandels3 commentedThis patch fixes the bug, transforming the format encoding to utf-8.
Comment #3
juandels3 commentedSorry. The previous patch was not for version 2.0.5 of the module. This one is.
Comment #4
juandels3 commentedComment #5
vuilComment #9
pheudo commentedI think that with the new version 2.1.x the problem no longer occurs.
Comment #10
vuilI close the issue as Fixed. Thank you.