WILD GUESS!!! Since you're NOT closing off the streams, PHP is trying to close them for you, but you've unset various variables and whatnot, and confused PHP into fclose()ing the WRONG thing. Try closing your own files. If that doesn't do it, just for fun, tack on an "exit;" at the very end of the script. This might get PHP to close the streams earlier than it normally would. This is a total hack, but there it is. File a bug report. http://bugs.php.net You seem to have a pretty clear-cut simple code-base to demonstrate the problem, so if you can provide that, it's odds-on that somebody on PHP Dev Team can fix it. On Fri, February 10, 2006 9:40 am, Jared Williams wrote: > >> > >> >>-----Original Message----- >> >>From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx] >> >>Sent: 10 February 2006 14:17 >> >>To: Jared.Williams@xxxxxxxxxxxx >> >>Cc: php-general@xxxxxxxxxxxxx >> >>Subject: Re: Debugging custom streams >> >> >> >>Jared Williams wrote: >> >> >> >>>Hi, >> >>> Short version, is there any way of listing all open >> >> >> >>resources from >> >> >> >>>within a PHP script? Think I may have a problem relating to >> >> >> >>the object/resource shutdown order within PHP, but cant see which >> >>custom stream handler still has an open resource. >> >> why not let your zip class keep a list of opened streams (I >> can't imagine that it's not doing that already) and write a >> function which will output a list of 'registered' stream >> resources that are still open [mis]using ftell() or feof() to >> check which streams are still 'active'. > > There can only be one open stream at a time, when writing, as a stream > writes to what will be the final zip file, and if they were > not closed in the correct manner the resulting zip file wouldn't be > valid. > > Perhaps I should explain in abit more detail how this is working. > > The ZipArchive creates two streams, one for the actual final zip, and > the another for the central directories headers. > > When fputs($stream, '0123456789') occurs the data goes through 2 > custom streams, and an optional filter. > > Zip custom stream -> optional compression filter -> Append custom > stream -> final zip file. > > The Zip custom stream, handles writing the local header to the final > zip file, calculating the compressed and uncompressed size, and > crc (using hash extension). Like so > > function stream_write($data) > { > $r = fwrite($this->compressedStream, $data); > $this->uncompressedSize += strlen($data); > hash_update($this->hashContext, $data); > return $r; > } > > When the Zip custom stream is closed the zip local header is rewritten > with the correct values, and a central directory header is > written to the central directory stream. So if any resource was left > open, then an invalid zip file would result. > > All $zip->close() has left todo, is append the central directory > stream contents to the final zip, add a central end directory > header and close both streams for a valid zip. > > Jared > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php