PHP XMLReader failing with huge input lookup error

222 views Asked by At

Suddenly, my code that has been working well started returning this error Message:

XMLReader::read(): compress.zlib://file.gz:2: parser error : internal error: Huge input lookup

This is happening on a cpanel server, but when I run it on my localhost, it runs properly.

I tried raising the memory limit on the server.

Any advice would be welcome.

1

There are 1 answers

1
Basooma John On

Following Chris Haas' advice, I modified my code to add LIB_XML_PARSEHUGE and it worked. My code now looks like this:

ini_set("memory_limit","20000M"); 
$file = 'file.gz'; 
$reader = new XMLReader(); 
$xmlfile = "compress.zlib://{$file}"; 
$reader->open($xmlfile,null,LIBXML_PARSEHUGE); 
while ($reader->read()) 
{ 
   //My logic here 
} 
$reader->close();