[dev] ILIAS 5.2.x: XML issues with PHP 5.6.x

Michael Jansen mjansen at databay.de
Mi Aug 16 15:13:10 CEST 2017

Dear developers and administrators,

the following information may save you some time as it took me a while to figure it out: 

Today I noticed some strange issues regarding XML handling in ILIAS with (v5.2.6 2017-07-13, PHP 5.6.31-4+ubuntu16.04.1+deb.sury.org+4). Initially, I discovered a problem in one of my plugins which deals with XML that uses simplexml_load_file() with a local(!) file.

The error message I got from it was:

simplexml_load_file(): I/O warning : failed to load external entity "[MY_FILE]"

I checked everything twice, the 'cwd', the include path, PHP ini settings ...
Surprisingly (for me), I was able to read the contents of the XML file one line before I called simplexml_load_file(). Passing the XML string to simplexml_load_string() worked fine.

The error occured randomly (I initially thought), so I really had no idea what could cause that. Then our administrators reported issues when copying/cloning courses via SOAP in customer installations. I exported and imported the course in question as XML into my local installation (which worked fine) and tried to copy the course to reproduce the reported issue afterwards. It worked perfectly with PHP 7.0, but failed with PHP 5.6. The error log contained the same I/O warning mentioned above.

When I added ...


... in my plugin before using simplexml_load_file() and before the ILIAS SOAP server is instantiated in ./webservice/soap/server.php, the issue seems to be fixed for both cases. 

libxml_disable_entity_loader() is not thread safe, so this is the root of all evil (including but not limited to pineapple on pizza). 

If ...


... is called in another script (or another PHP application) and not resetted to false, the problematic state persists globally. There are even some calls of with a boolean true in ILIAS (PHPExcel, SVG Sanitizer), which is dangerous in case an error occured and the state could not be properly resetted to a boolean false.

Best regards,

Mehr Informationen über die Mailingliste developers