Migrations fail if langcode contains hyphen

Created on 20 June 2019, over 5 years ago
Updated 6 February 2024, 9 months ago

Some langcodes contain hyphens, for example:

  • pt-pt
  • gsw-berne
  • zh-hans

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Language%...

If a hyphenated langcode is provided in a migration ID, for example node_product:pt-pt, the following error occurs when the migration runs:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-pt (
`source_ids_hash` VARCHAR(64) NOT NULL COMMENT 'Hash of source ids. Used ' at line 1: CREATE TABLE {migrate_map_node_product__pt-pt} (

This is caused by insufficient sanitisation of the migration machine name in core/modules/migrate/src/Plugin/migrate/id_map/Sql.php.

Hyphens are not allowed in database table names.

πŸ› Bug report
Status

Closed: works as designed

Version

10.2 ✨

Component
MigrationΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¬πŸ‡§United Kingdom JamieP

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom mrhorse

    We still have need for the functionality provided by the patch - just re-rolled it for D10.2.2 but not re-opening the ticket for obvious reasons.

Production build 0.71.5 2024