Skip to content

Commit 7d15cf4

Browse files
committed
bug #37763 Fix deprecated libxml_disable_entity_loader (jderusse)
This PR was merged into the 3.4 branch. Discussion ---------- Fix deprecated libxml_disable_entity_loader | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | / | License | MIT | Doc PR | / Fix deprecation `Function libxml_disable_entity_loader() is deprecated` triggered by php/php-src#5867 in PHP8 Commits ------- 1f19da3936 Fix deprecated libxml_disable_entity_loader
2 parents f63cb69 + 3c61512 commit 7d15cf4

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)