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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3003986-2.patch | 619 bytes | jrockowitz |
Comments
Comment #2
jrockowitz commentedDoh!!! You can see by the patch that the solution is really simple.
Comment #4
jrockowitz commentedI committed the patch. Please download the latest dev release to review.