Intermittent simplexml_load_file (): I / O warning on local Joomla site

I just started getting intermittent error on all pages of the joomla devom site where I am running on localhost.

Full warning:

Warning: simplexml_load_file(): I/O warning : failed to load external entity "/site/language/en-GB/en-GB.xml" in /site/libraries/joomla/language/language.php on line 1354

The strange thing is that it is intermittent, and some updates usually solve the problem.

Is there a problem with the code that might cause this or is it something else?

+6
source share
2 answers

In the early days, it has not yet been conclusively said that this fix works, but it seems to be fixed at the moment.

EDIT: I have not seen a repeat since this change was made, so I can confirm that this resolved the problem.

add libxml_disable_entity_loader(false); in joomla index.php

Credit is sent to Corneliu on the Joomla forum for posting in this thread:

J! 3.1.6 / 3.2 simplexml_load_file, JForm :: getInstance errors

+5
source

Let me bring it here just in case someone answers Google and a solution with unsafe libxml_disable_entity_loader(false) not applicable. The following is a potential vulnerability to enable an object loader in the system:

 <!DOCTYPE scan [<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=/etc/passwd">]> <scan>&test;</scan> 

The issue of thread insecurity is explained here. Although you can register your own object loader with libxml_set_external_entity_loader or use locks to protect calls to libxml_disable_entity_loader , these solutions seem a little perplexing.

The good news is that the problem with external objects only affects file- related functions (e.g. simplexml_load_file , DOMDocument::schemaValidate , etc.). This makes the solution simple and straightforward. First load the contents of the file as a string, and then execute the corresponding libxml string string.

 simplexml_load_string(file_get_contents($xml)); 

and / or

 $xml = new DOMDocument('1.0', 'UTF8'); $xml->loadXML(file_get_contents($xmlFile)); $xml->schemaValidateSource(file_get_contents($xsdFile)); 

Hope this helps someone.

+8
source

All Articles