Skip to content

Commit

Permalink
XmlDriver: Avoid PHP bug #62577 by avoiding simplexml_load_file.
Browse files Browse the repository at this point in the history
Doctrine is affected by PHP bug #62577. simplexml_load_file is not
able to load files if libxml_disable_entity_loader(true) has been
called. simplexml_load_file fails with the message:

I/O warning : failed to load external entity "/my/mappings/my_entity.dcm.xml"
in /path-to/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 711

This error occurs even if there are no external entities in the XML file.

Waiting for the PHP bug to be resolved is infeasible, because it is
unresolved since years. Therefore Doctrine needs to circumvent the bug
by replacing simplexml_load_file with simplexml_load_string while getting
the file contents itself. simplexml_load_string is not affected by the
PHP bug.
  • Loading branch information
Aljosha Papsch authored and Ocramius committed Aug 18, 2017
1 parent 82e0d7e commit d7e1f88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ private function _getCascadeMappings(SimpleXMLElement $cascadeElement)
protected function loadMappingFile($file)
{
$result = array();
$xmlElement = simplexml_load_file($file);
$xmlElement = simplexml_load_string(file_get_contents($file));

if (isset($xmlElement->entity)) {
foreach ($xmlElement->entity as $entityElement) {
Expand Down

0 comments on commit d7e1f88

Please sign in to comment.