note 94505 added to function.fopen

From: Date: Mon, 09 Nov 2009 15:45:16 +0000
Subject: note 94505 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-162661@lists.php.net to get a copy of this message
Take great care if you project to use both ftp and compression wrapper within fopened stream to remotely write a compressed file built on the fly. This code : <? $resFile = fopen('compress.bzip2://./test.rnd.bz2', 'wb'); for ($i=0; $i < 1000000 ; $i++) { fwrite($resFile, chr(rand(255))); } close($resFile); ?> will produce a well formed bz2 compressed random content file. <? $resFile = fopen('compress.bzip2://ftp://blah/test.rnd.bz2', 'wb'); for ($i=0; $i < 1000000 ; $i++) { fwrite($resFile, chr(rand(255))); } close($resFile); ?> will produce a corrupted bz2 compressed random content file. The file is not really corrupted, it is incomplete. The tail of the file is not written to the stream, the file is truncated at the end of complete compressed data block. Adding fflush($resFile); before closing the file does not fix this issue. This problem can be reproduced with PHP 5.2.6 (bundled with Debian 2.6.26-13lenny2) and may be related to http://bugs.php.net/bug.php?id=42117. ---- Server IP: 195.221.21.36 Probable Submitter: 82.226.210.5 ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- https://master.php.net/note/edit/94505 Del: integrated -- https://master.php.net/note/delete/94505/integrated Del: useless -- https://master.php.net/note/delete/94505/useless Del: bad code -- https://master.php.net/note/delete/94505/bad+code Del: spam -- https://master.php.net/note/delete/94505/spam Del: non-english -- https://master.php.net/note/delete/94505/non-english Del: in docs -- https://master.php.net/note/delete/94505/in+docs Del: other reasons-- https://master.php.net/note/delete/94505 Reject -- https://master.php.net/note/reject/94505 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#162661) next »