Source element values are replaced with translated values

Created on 3 October 2017, almost 7 years ago
Updated 21 February 2024, 7 months ago

Problem/Motivation

We have a multilingual site (German - default, English - second language) and enabled config entity translations for webform entities.
The site has a webform which was originally created in English and has a German translation.

English (source) element values:

first_name:
  '#title': 'First name'
  '#type': textfield
  '#required': true
last_name:
  '#title': 'Last name'
  '#type': textfield
  '#required': true

German translation:

first_name:
  '#title': Vorname
last_name:
  '#title': Nachname

Our site was on webform-beta15 version and we wanted to webform-beta17 version.

After an update to webform-beta17, our webform has disappeared from the page.

After some investigation, we realized that English element (YAML) values were replaced with a German translation and thus lost their field type identifiers which resulted in no display.

This is our understanding of what happened:

  1. composer update drupal/webform
  2. drush updb triggered webform_update_8072() which loaded a webform entity. Because the site's default language is German the webform entity replaced elements property with a german translation values which contains no field type keys. webform_update_8072() calls save() on a webform entity which replaced the original elements values.
  3. Webform failed to display a webform as there is no field #type identifiers in the source elements property

Notes

Below are the quickest step to reproduce this bug

  • Install Webform in English
  • Enable Configuration Translation (/admin/modules)
  • Add 'Spanish' language (/admin/config/regional/language/add)
  • Translate at least one element for the default Contact webform into Spanish (/admin/structure/webform/manage/contact/translate/es/add)
  • Switch the site's default language to Spanish (/admin/config/regional/language)
  • Execute this Drush command drush php-eval '\Drupal\webform\Entity\Webform::load('contact')->save()';
  • Confirm that the Contact webform element's are replaced with the Spanish translation (/es/admin/structure/webform/manage/contact/source)

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed

Version

5.0

Component

Translation

Created by

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.

  • 🇳🇱Netherlands seanB Netherlands

    The attached patch seems to solve (at least part) of the issue for us. It's probably not a long-term solution, so just uploading this in case it helps anyone.

Production build 0.71.5 2024