Skip to content

Illegal mix of collations for operation #40138

@Nuranto

Description

@Nuranto

Preconditions and environment

  • Magento version 2.4.8-p1
  • PHP 8.3

Steps to reproduce

  1. Add a special character (multybyte) in postcode field
  2. go to checkout to trigger a shipping estimatation

Expected result

No error

Actual result

SQLSTATE[HY000]: General error: 1271 Illegal mix of collations for operation 'in', query was:

SELECT main_table.tax_calculation_rate_id, main_table.tax_calculation_rule_id, main_table.customer_tax_class_id, main_table.product_tax_class_id, rule.priority, rule.position, rule.calculate_subtotal, rate.rate AS value, rate.tax_country_id, rate.tax_region_id, rate.tax_postcode, rate.tax_calculation_rate_id, rate.code, IF(title_table.value IS NULL, rate.code, title_table.value) AS title FROM tax_calculation AS main_table
 INNER JOIN tax_calculation_rule AS rule ON rule.tax_calculation_rule_id = main_table.tax_calculation_rule_id
 INNER JOIN tax_calculation_rate AS rate ON rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id
 LEFT JOIN tax_calculation_rate_title AS title_table ON rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '1' WHERE (customer_tax_class_id = 3) AND (product_tax_class_id IN ('2')) AND (rate.tax_country_id = 'FR') AND (rate.tax_region_id IN(0, 0)) AND (rate.zip_is_range IS NULL) AND (rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', '⠀', '⠀*', '�*', '�*')) ORDER BY priority ASC, tax_calculation_rule_id ASC, tax_country_id DESC, tax_region_id DESC, tax_postcode DESC, value DESC

Additional information

Solution is in src/vendor/magento/module-tax/Model/ResourceModel/Calculation.php::_createSearchPostCodeTemplates : replacing string methods by their mb_ equivalent solves the issue. I will create a PR asap.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Labels

Issue: needs updateAdditional information is require, waiting for responseReported on 2.4.8-p1Indicates original Magento version for the Issue report.

Type

No type

Projects

Status

Needs Update

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions