Re: #24865 [Asn]: [patch] let XML_RSS, XML_Parser accept string inputs
| From: | Martin Jansen | Date: | Sat, 23 Aug 2003 10:43:24 +0000 |
| Subject: | Re: #24865 [Asn]: [patch] let XML_RSS, XML_Parser accept string inputs | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20437@lists.php.net to get a copy of this message | ||
On Sat Aug 23, 2003 at 12:1036PM +0200, Stephan Schmidt wrote:
> The parse() method was changed in a very bad way:
>
> // if $this->fp was fopened previously
> if (is_resource($this->fp)) {
> // write entire file to $data
> while (!feof($this->fp)) {
> $data .= fread($this->fp, 2048);
> }
> fclose($this->fp);
> // otherwise, $this->fp must be a string
>
> If you hand over a resource, the whole file is read into memory. Imagine
> parsing huge files (100MB and up). This will result in avoidable memory
> consumption and even in a fatal error "Memory limit exceeded". There
> should NOT be a release including this patch.
You're right. I only applied the patch to the source tree to have it in
CVS and to move it from one part of my todo list to another. I'm also
planning to review the other part of the patch later, but as you are
working on the code anyway, I'll postpone that until you've finished
your patch.
--
- Martin Martin Jansen
http://martinjansen.com/