Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created June 15, 2018 14:24
Show Gist options
  • Select an option

  • Save mttjohnson/c7fde5d9f064c94ddf1fff389ed8bbf0 to your computer and use it in GitHub Desktop.

Select an option

Save mttjohnson/c7fde5d9f064c94ddf1fff389ed8bbf0 to your computer and use it in GitHub Desktop.
PHP XML 10MB Limit
Other people have run into this issue:
Warning: DOMDocumentFragment::appendXML(): Entity: line 1: parser error : CData section too big found in /magento/lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/Template.php on line 60
https://github.com/magento/magento2/issues/4695
https://github.com/magento/magento2/issues/8084
Not saying they figured much out, but other people have been experiencing the issue as well.
The limit comes from the libxml library that PHP uses for XML processing:
http://php.net/manual/en/domdocument.loadxml.php#113676
libxml introduced a limit for safety purposes, with the ability to pass an option to override the default 10MB limit.
http://xmlsoft.org/html/libxml-parserInternals.html#XML_MAX_TEXT_LENGTH
That was introduced in libxml 2.9.0 release in Setpember 2012.
You can check to see what version of libxml is on a system:
php -i | grep libxml
The appendXML method is not part of the DOM standard, and the DOMDocumentFragment::appendXML method does not provide the option to pass LIBXML_PARSEHUGE to the method like you can with DOMDocument::loadXML.
http://php.net/manual/en/domdocumentfragment.appendxml.php
It looks like it's the parser that complains about the size, so it may be possible to work around the issue and instead of using appendXML, use loadXML and implement appendXML differently to include the options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment