magento2: Magento 2.1 EE: simplexml_load_string() error in custom widget
Preconditions
- OS of the server: Debian (Virtualized, with 3GB of memory)
- OS of the client: Windows 7
- * Browser of the client*: Chrome Version 52.0.2743.116 m (64-bit). Also tried with Firefox 44.0.2
- MySQL: Ver 14.14 Distrib 5.6.31
- PHP: PHP 7.0.8-1~dotdeb+8.1 (cli) ( NTS )
Steps to reproduce
- Create a custom widget from a XML file
- Put a text field
- In the backend Content->Widget section, add the widget to a page
- In the widget content, set some HTML code like this:
<p>Bonjour éàùè ô</p>
Expected result
- The text should be displayed
Actual result
A warning is raised :
Exception #0 (Exception): Warning: simplexml_load_string(): Entity: line 1: parser error : Entity 'eacute' not defined in /var/www/xx/vendor/magento/framework/View/Model/Layout/Merge.php on line 493
Notes:
- if, instead of the text field, a I put a WYSIWYG one, and put some HTML code, it will generate entities encoded HTML
- if I put only raw text: no problem.
- more weird: if I put only raw text, then I save, everything is OK. And if I come later, put some HTML code (directly or via the WYSIWYG), and save, I have a warning:

About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (9 by maintainers)
I did find some sort of solution for this issue, although I’m not sure if its really a bug because technically those elements are invalid XML and shouldn’t be use in widgets. However most clients do just put in these types of characters and then Magento converts them into HTML Entities on Save and this is just read straight into XML.
If you put a preference on the
_loadXmlString()method inMagento\Framework\View\Model\Layout\Mergeline 491You can do something like:
For anyone who doesn’t want to wait for 2.2.x you can use this small module to apply the fix https://github.com/WeareJH/m2-core-bug-simplexml-widget