Problem/Motivation

During work on #2409701: Field storage configuration is not exposed to config translation UI, a bug with translation of "sequence" data types was discovered.

Exported translated configuration looked like this:

settings:
  allowed_values:
    label: string1
    1:
      label: string2

While it was expected to look like this:

settings:
  allowed_values:
    -
      label: string1
    -
      label: string2

Bug source

In \Drupal\config_translation\FormElement\ListElement::setConfig(), the following string creates the element ID appending the element key to the base key (which may be not provided, so NULL).

$element_key = implode('.', array_filter(array($base_key, $key)));

The problem is that for sequences, the key could be "0", so it's filtered by the array_filter() function.

Proposed resolution

Change the code to:

$element_key = ltrim("$base_key.$key", '.');

Remaining tasks

+ create patch
- write tests

User interface changes

none

API changes

none

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Leksat’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
1.42 KB

No tests yet.

Schnitzel’s picture

Issue tags: +D8MI

tagging

Schnitzel’s picture

Issue tags: +Needs tests
tstoeckler’s picture

Status: Needs review » Closed (duplicate)

Thanks for reporting this! Unfortunately you are not the first to hit this problem...

This is a duplicate of #2395627: Do not remove 0 from config translation data. That one has tests, but I like the ltrim() approach here better than the one used there. That one introduces a separate method for this, though, which I think makes sense. Maybe we can just merge the two patches?