Skip to content

Commit 3c61512

Browse files
committed
Fix deprecated libxml_disable_entity_loader
1 parent 3a14abc commit 3c61512

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Loader/XmlFileLoader.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,13 @@ public function validateSchema(\DOMDocument $dom)
620620
EOF
621621
;
622622

623-
$disableEntities = libxml_disable_entity_loader(false);
624-
$valid = @$dom->schemaValidateSource($source);
625-
libxml_disable_entity_loader($disableEntities);
623+
if (LIBXML_VERSION < 20900) {
624+
$disableEntities = libxml_disable_entity_loader(false);
625+
$valid = @$dom->schemaValidateSource($source);
626+
libxml_disable_entity_loader($disableEntities);
627+
} else {
628+
$valid = @$dom->schemaValidateSource($source);
629+
}
626630

627631
foreach ($tmpfiles as $tmpfile) {
628632
@unlink($tmpfile);

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ public function testParseFile()
9595

9696
public function testLoadWithExternalEntitiesDisabled()
9797
{
98-
$disableEntities = libxml_disable_entity_loader(true);
98+
if (LIBXML_VERSION < 20900) {
99+
$disableEntities = libxml_disable_entity_loader(true);
100+
}
99101

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

104-
libxml_disable_entity_loader($disableEntities);
106+
if (LIBXML_VERSION < 20900) {
107+
libxml_disable_entity_loader($disableEntities);
108+
}
105109

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

0 commit comments

Comments
 (0)