6

I've just started getting an intermittent error on all pages of a joomla dev site I'm running on localhost.

The full warning is:

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 a few refreshes will usually resolve the problem.

Is there a code problem that could be causing this or is it something else?

9
  • An intermittent I/O warning sounds like it could be a system/hardware issue perhaps? Maybe a full hard disk or something?
    – Pekka
    Dec 12, 2013 at 4:10
  • @Pekka웃 Thanks for the reply, I just checked that and there is 65GB free on ssd so that isn't it. Also, it's always the same file which is strange...
    – doovers
    Dec 12, 2013 at 4:16
  • Hmm. Not sure how to debug this (and get an actual useful error message instead of the pointless "I/O warning")
    – Pekka
    Dec 12, 2013 at 4:19
  • Race conditions for the file handler from something else? Dec 12, 2013 at 4:23
  • @Zarazthuztra Thank you for your reply, would you mind explaining your suggestion as I don't understand!
    – doovers
    Dec 12, 2013 at 4:30

2 Answers 2

9

Let me put it here just in case for somebody will google for an answer and the solution with not thread-safe libxml_disable_entity_loader(false) will not be applicable. The potential vulnerability of enabling the entity loader system-wide is shown below:

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

The problem caused by the lack of thread safety is explained here. Although one might either register her own entity loader with libxml_set_external_entity_loader, or use locks to protect calls to libxml_disable_entity_loader, these solutions seem a bit puzzling.

The good news is that the problem with external entities affects only the functions dealing with files (e.g. simplexml_load_file, DOMDocument::schemaValidate and like). That makes the solution straight and simple. First load file content as string and then execute the respective libxml string-oriented function.

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 it helps somebody.

5

It's early days yet to say conclusively that this fix works but it seems to have fixed it for now.

EDIT: Haven't seen any reoccurrence since making this change so I can confirm that this has resolved the problem.

add libxml_disable_entity_loader(false); to joomla's index.php

Credit goes to Corneliu on the Joomla forum for his post in this thread:

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

2
  • Thank you so much for this, I'm on php v5.5.3, and simplexml_load_file just wouldn't work at all, even with perfectly accessible local files. This solution worked for me. Jan 10, 2014 at 15:37
  • Great info!!! Doovers, thanks for the info and the link. I ran into the same issue that killed a Magento store today, and this function saved me. My problem was also related to Piwik.
    – Jon
    May 21, 2014 at 22:11

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.