5

I have this issue in my magento installation

Warning: simplexml_load_file(): I/O warning : failed to load external entity "/var/www/app/etc/local.xml" in /var/www/app/Mage.php on line 767

setting libxml_disable_entity_loader(false); solves this issue but I will have to do it for every simplexml_load_file()

Is there any better solution and also if anyone could shed some light on how this issue might have occurred?

  • 1
    The community can provide better/more details answers for you if you provide mor information (Magento/PHP versions, extensions, latest changes), otherwise it's difficult to guess. Regarding your problem: * app/etc/local.xml is maye not readable: Check file permissions, * Possible XML-Error in config files? Did you make changes lately? * PHP Bug with PHP Version master-Git-2012-07-16: bugs.php.net/bug.php?id=62577 – Anna Völkl Jul 25 '14 at 7:00
  • The XML is missing in your question as well. You for sure need to provide more information here. Also it's not clear from your question what your understanding of the error message is. – hakre Jul 26 '14 at 8:53
3

As a followup on this: I have the same issue as well - randomly - when loading any XML file using simplexml_load_file() on the same server with any application (WordPress, Magento, Joomla). The reason is definitely not that the XML file contains bad characters, bad formatting or does not exist. The issue seems to be related to a pending PHP bug, that occurs when too many PHP applications rely on SimpleXML on the same server.

On a deeper level, the SimpleXML library uses kind of caching that is persistent across multiple requests within the same PHP thread (PHP-FPM instance, mod_php instance, etcetera). It is said to be fixed by updating PHP 5.4, but that hasn't worked yet for me. It does not occur with PHP 5.5 or higher.

One fix is to override app/Mage.php with the following - locate the commented line and replace it with 3 lines. Core hack, ugly, should not be done, wash your mouth. But it works.

//$localConfig = simplexml_load_file($localConfigFile); $xmlString = file_get_contents($localConfigFile); $localConfig = simplexml_load_string($xmlString);

Another workaround is listed here: https://bugs.php.net/bug.php?id=64938

2

Perhaps best described in Magento context this is as:

There was a problem parsing the config file.

This can be due to an error in the software used (Magento, PHP) or due to an error with the config file or both.


Is there any better solution

I would not disable the entity loader but fix the root cause of the problem. It's most often always a better solution to fix a root-cause instead of hiding error messages.

and also if anyone could shed some light on how this issue might have occurred?

PHP's SimpleXMLElement extension is unable to load the XML file. This is due to the XML in that file. As you have not shown the XML, there is not much more that can be said about it as you haven't even shared your level of understanding as well nor which software (Magento, PHP) and library versions (libxml) has been used.

That might just be a flaw in the software but also can be an error in your Magento configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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