Skip to content

Commit

Permalink
Fix deprecated libxml_disable_entity_loader
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Aug 9, 2020
1 parent 3a14abc commit 3c61512
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions Loader/XmlFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,13 @@ public function validateSchema(\DOMDocument $dom)
EOF
;

$disableEntities = libxml_disable_entity_loader(false);
$valid = @$dom->schemaValidateSource($source);
libxml_disable_entity_loader($disableEntities);
if (LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(false);
$valid = @$dom->schemaValidateSource($source);
libxml_disable_entity_loader($disableEntities);
} else {
$valid = @$dom->schemaValidateSource($source);
}

foreach ($tmpfiles as $tmpfile) {
@unlink($tmpfile);
Expand Down
8 changes: 6 additions & 2 deletions Tests/Loader/XmlFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ public function testParseFile()

public function testLoadWithExternalEntitiesDisabled()
{
$disableEntities = libxml_disable_entity_loader(true);
if (LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}

$containerBuilder = new ContainerBuilder();
$loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('services2.xml');

libxml_disable_entity_loader($disableEntities);
if (LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}

$this->assertGreaterThan(0, $containerBuilder->getParameterBag()->all(), 'Parameters can be read from the config file.');
}
Expand Down

0 comments on commit 3c61512

Please sign in to comment.