Problem/Motivation

When the Drupal 7 migration database fixture gets migrated with config_translation enabled, the migrated translation for field.storage.node.field_rating causes warnings – because the numeric key of the option label translations does not match the keys of the original field configuration entity:

Source field.storage.node.field_rating storage config entity:

uuid: fc9bc891-d92c-4034-8092-0c6b4ec7cf73
langcode: und
status: true
[...]
settings:
  allowed_values:
    -
      value: '1'
      label: High
    -
      value: '2'
      label: Medium
    -
      value: '3'
      label: Low
  allowed_values_function: ''
module: options
[...]

(French) translation:

settings:
  allowed_values:
    1:
      label: Haute
    2:
      label: Moyenne
    3:
      label: Faible

Since the translations of the other option list field field.storage.node.field_color seem to be fine, I strongly believe that this issue is caused by wrong source data, and not by a wrong migration plugin.

Proposed resolution

The translations of the allowed values are stored as an indexed array, in the same order of the allowed values and starting at zero. The order was correct but it was not starting at zero.

Remaining tasks

Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

huzooka’s picture

Title: Fix "d7_field_option_translation" source plugin OR the migration database fixture » Fix "d7_field_option_translation" migrate source plugin OR the migration database fixture
Wim Leers’s picture

I strongly believe that this issue is caused by wrong source data, and not by a wrong migration plugin.

I suspect the same!

quietone’s picture

Title: Fix "d7_field_option_translation" migrate source plugin OR the migration database fixture » Fix "d7_field_option_translation" process plugin
Issue summary: View changes
FileSize
2.77 KB

On a fresh D7 site I have made a few list_text fields and looked at the results in field_config and they match what is in the D7 test fixture. In other words, the error is not in the source fixture.

The translations of the allowed values are stored as an indexed array, in the same order of the allowed values and starting at zero. The order was correct but it was not starting at zero. This patch will put the translation in the correct position in the allowed values as seen here in the results for field_rating from /sync/language/fr/field.storage.node.field_rating.yml.

settings:
  allowed_values:
    -
      label: Haute
    -
      label: Moyenne
    -
      label: Faible

Manual testing confirmed that warning are not generated. Personally, I think manual testing is sufficient. The existing test was incorrect and that has been fixed.

Edit: s/get put/put

quietone’s picture

Status: Active » Needs review
Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

I trust @quietone's thorough analysis 🤓

quietone’s picture

@Wim Leers, thank you. I hope the committer agrees!

alexpott’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

I checked that the Drupal 6 version of the plugin does not make the same mistake and it appears to not.

Committed and pushed d1064c3 to 9.2.x and 45c43f6624 to 9.1.x. Thanks!

  • alexpott committed d1064c3 on 9.2.x
    Issue #3187463 by quietone, huzooka: Fix "d7_field_option_translation"...

  • alexpott committed 45c43f6 on 9.1.x
    Issue #3187463 by quietone, huzooka: Fix "d7_field_option_translation"...

Status: Fixed » Closed (fixed)

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