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

XmlDriver: simplexml_load_file is unreliable, should be avoided #6624

Closed
apapsch opened this issue Aug 14, 2017 · 1 comment
Closed

XmlDriver: simplexml_load_file is unreliable, should be avoided #6624

apapsch opened this issue Aug 14, 2017 · 1 comment

Comments

@apapsch
Copy link

apapsch commented Aug 14, 2017

XmlDriver uses SimpleXml which is not reliable to load files. Sometimes SimpleXml may successfully load file, sometimes fail with:

simplexml_load_file(): I/O warning : failed to load external entity "<filename>" in /.../doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 814

Doctrine subsequently throws exception, whose message is somewhat misleading, as the complained about file exists and is perfectly valid:

Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'Invalid mapping file '<filename>' for class '<class name>'.' in /.../doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php:86

[1] suggests that is has to do with SimpleXml thread issues. I'm ever more suspicious because entity files are affected which haven't changed in months.

To fix this issue short-term applications may call libxml_disable_entity_loader(false);, but applications shouldn't need to care about the XML reader Doctrine uses internally. As [1] suggests as solution, users of SimpleXml should avoid SimpleXml functions which operate on files, e.g. replace simplexml_load_file(...) with simplexml_load_string(file_get_contents(...)).

[1] https://stackoverflow.com/questions/20534866/intermittent-simplexml-load-file-i-o-warning-on-local-joomla-site

@Ocramius
Copy link
Member

Duplicate of #3788

@Ocramius Ocramius marked this as a duplicate of #3788 Aug 14, 2017
@Ocramius Ocramius self-assigned this Aug 14, 2017
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