Problem/Motivation

When translating a webform part of the translation consist out of a YAML chunk. As YAML is very strict it can occur that a character has been replaced causing the YAML to be invalid.
When you try to save this form containing invalid YAML the whole form will encounter a PHP fatal error like:

Drupal\Component\Serialization\Exception\InvalidDataTypeException: Malformed inline YAML string: 'Please ignore this email. at line 12 (near "'#test': 'Please ignore this email."). in Drupal\Component\Serialization\YamlSymfony::decode() (line 40 of /home/dmpgw/www/core/lib/Drupal/Component/Serialization/YamlSymfony.php).

How to reproduce

Make sure your website is multilingual (at least 2 languages enabled)
Enable translation modules
Enable webform (moment of issue: 8.x-5.0-rc22)
Translate default created webform 'Contact': /admin/structure/webform/manage/contact/translate
On the translate form, for example remove a quot. (Eg. '#title': 'Your Email' > '#title': 'Your Email)
Try to save the form

This was tested in simplytestme using the latest version of webform.

Proposed resolution

Database logging logs the error correctly explaining where the YAML is invalid.
On save of the translation is would be nice to try and serialize the YAML translation and catch any error so the message of the error could explain site editors that there is an error in the translation rather then simply not catching the error on submit.

CommentFileSizeAuthor
#2 3003986-2.patch619 bytesjrockowitz

Comments

KevinVb created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new619 bytes

Doh!!! You can see by the patch that the solution is really simple.

  • jrockowitz committed 724fdec on 8.x-5.x
    Issue #3003986 by jrockowitz: PHP fatal serialization error when trying...
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

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