I am upgrading to PHP 8 and getting the following warning:
Function libxml_disable_entity_loader() is deprecated
What I have: This code saves the current entity loader status, and enables the loader; then loads the file; and finally resets the entity loader to its original status:
...
$current = libxml_disable_entity_loader(false);
$domdocument->load($filename,$options);
libxml_disable_entity_loader($current);
...
I read the following regarding PHP 8:
as of libxml 2.9.0 entity substitution is disabled by default, so there is no need to disable the loading of external entities, unless there is the need to resolve internal entity references with LIBXML_NOENT.
To test, I removed the libxml_disable_entity_loader() references, thus What I have: becomes:
...
$domdocument->load($filename,$options);
...
However, now of course I get:
PHP Warning: DOMDocument::load(): I/O warning : failed to load external entity
So, my question is:
What do I need to do in PHP 8 to get rid of libxml_disable_entity_loader() and still achieve the equivalent of What I have: