File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -199,7 +199,9 @@ public function testLoadEmptyXmlFile()
199199 // test for issue https://github.com/symfony/symfony/issues/9731
200200 public function testLoadWrongEmptyXMLWithErrorHandler ()
201201 {
202- $ originalDisableEntities = libxml_disable_entity_loader (false );
202+ if (LIBXML_VERSION < 20900 ) {
203+ $ originalDisableEntities = libxml_disable_entity_loader (false );
204+ }
203205 $ errorReporting = error_reporting (-1 );
204206
205207 set_error_handler (function ($ errno , $ errstr ) {
@@ -219,12 +221,13 @@ public function testLoadWrongEmptyXMLWithErrorHandler()
219221 error_reporting ($ errorReporting );
220222 }
221223
222- $ disableEntities = libxml_disable_entity_loader (true );
223- libxml_disable_entity_loader ($ disableEntities );
224-
225- libxml_disable_entity_loader ($ originalDisableEntities );
224+ if (LIBXML_VERSION < 20900 ) {
225+ $ disableEntities = libxml_disable_entity_loader (true );
226+ libxml_disable_entity_loader ($ disableEntities );
226227
227- $ this ->assertFalse ($ disableEntities );
228+ libxml_disable_entity_loader ($ originalDisableEntities );
229+ $ this ->assertFalse ($ disableEntities );
230+ }
228231
229232 // should not throw an exception
230233 XmlUtils::loadFile (__DIR__ .'/../Fixtures/Util/valid.xml ' , __DIR__ .'/../Fixtures/Util/schema.xsd ' );
Original file line number Diff line number Diff line change @@ -51,21 +51,27 @@ public static function parse($content, $schemaOrCallable = null)
5151 }
5252
5353 $ internalErrors = libxml_use_internal_errors (true );
54- $ disableEntities = libxml_disable_entity_loader (true );
54+ if (LIBXML_VERSION < 20900 ) {
55+ $ disableEntities = libxml_disable_entity_loader (true );
56+ }
5557 libxml_clear_errors ();
5658
5759 $ dom = new \DOMDocument ();
5860 $ dom ->validateOnParse = true ;
5961 if (!$ dom ->loadXML ($ content , LIBXML_NONET | (\defined ('LIBXML_COMPACT ' ) ? LIBXML_COMPACT : 0 ))) {
60- libxml_disable_entity_loader ($ disableEntities );
62+ if (LIBXML_VERSION < 20900 ) {
63+ libxml_disable_entity_loader ($ disableEntities );
64+ }
6165
6266 throw new XmlParsingException (implode ("\n" , static ::getXmlErrors ($ internalErrors )));
6367 }
6468
6569 $ dom ->normalizeDocument ();
6670
6771 libxml_use_internal_errors ($ internalErrors );
68- libxml_disable_entity_loader ($ disableEntities );
72+ if (LIBXML_VERSION < 20900 ) {
73+ libxml_disable_entity_loader ($ disableEntities );
74+ }
6975
7076 foreach ($ dom ->childNodes as $ child ) {
7177 if (XML_DOCUMENT_TYPE_NODE === $ child ->nodeType ) {
You can’t perform that action at this time.
0 commit comments