Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to specify libxml options #828

Open
tehplague opened this issue Oct 16, 2017 · 2 comments
Open

Provide a way to specify libxml options #828

tehplague opened this issue Oct 16, 2017 · 2 comments

Comments

@tehplague
Copy link

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no

Currently JMS Serializer has some issues when handling large XML datasets. However, SimpleXML or rather libxml2, to be precise, allows to specify parameters to simplexml_load_string and related methods that influence libxml's handling of incoming XML.

Among the available ones LIBXML_COMPACT (trying harder to allocate memory more efficiently) and LIBXML_PARSEHUGE (bypassing some hardcoded limitations inside libxml) are interesting when deserializing large XML bodies. As the invocation of simplexml_load_string is hardcoded in the XmlDeserializationVisitor that class needs to be overridden if one wants to change its parameters.

Thus, I propose to provide a configuration interface that allows to control the configuration of libxml for use in JMS Serializer, i.e. in \JMS\Serializer\XmlDeserializationVisitor::prepare

Steps required to reproduce the problem

  1. Deserialize a large XML body with JMS Serializer

Expected Result

  • Deserialized object structure

Actual Result

  • Exception parser error : internal error: Huge input lookup which goes away if one modifies said invocation of simplexml_load_string into:
        $doc = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
@goetas
Copy link
Collaborator

goetas commented Oct 16, 2017

Make sense. something similar was implemented for the json serializer (here)

@goetas
Copy link
Collaborator

goetas commented Apr 26, 2018

PR is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants