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.

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

juandels3 created an issue. See original summary.

juandels3’s picture

StatusFileSize
new596 bytes

This patch fixes the bug, transforming the format encoding to utf-8.

juandels3’s picture

StatusFileSize
new613 bytes

Sorry. The previous patch was not for version 2.0.5 of the module. This one is.

juandels3’s picture

Status: Needs work » Needs review
vuil’s picture

Version: 2.0.5 » 2.0.x-dev

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

pheudo’s picture

I think that with the new version 2.1.x the problem no longer occurs.

vuil’s picture

Status: Needs review » Fixed

I close the issue as Fixed. Thank you.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.