Doc #70819 [Ver->Csd]: bzflush() is a null function

From: Date: Thu, 10 Dec 2020 12:34:10 +0000
Subject: Doc #70819 [Ver->Csd]: bzflush() is a null function
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18240@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70819&edit=1 ID: 70819 Updated by: phpdocbot@php.net Reported by: mail at jerrygrey dot me Summary: bzflush() is a null function -Status: Verified +Status: Closed Type: Documentation Problem Package: Streams related Operating System: Irrelevant PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmb Revision: http://git.php.net/?p=doc/en.git;a=commit;h=d5fafb8e37413e5d0bd74dec1797de591cb9bad1 Log: Fix #70819: bzflush() is a null function Previous Comments: ------------------------------------------------------------------------ [2020-12-10 12:32:09] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=351993 Log: Fix #70819: bzflush() is a null function ------------------------------------------------------------------------ [2020-12-10 12:31:09] cmb@php.net After having a closer look at this, forget about the alias thing; while technically correct, that info is not useful for users. Actually, reeze is right, we're calling BZ2_bzflush() which is supposed to give better zlib compatibility[1], but completely fails to do so (if it does nothing, it should not claim success). [1] <https://www.sourceware.org/bzip2/manual/manual.html#zlib-compat> ------------------------------------------------------------------------ [2020-12-10 04:26:03] mail at jerrygrey dot me Salsi, as I said above, if this isn't a bug, it should be documented. The PHP documentation for bzflush to this day says nothing more than "Forces a write of all buffered bzip2 data for the file pointer bz." Speaking for myself, at the time, I was mislead by the documentation. A short sentence or two on the documentation to note this behaviour would have saved me a ton of time and frustration. ------------------------------------------------------------------------ [2020-12-09 18:07:18] cmb@php.net Well, I think we should clearly document that bzflush() is an alias of fflush(), and that bzwrite() and bzclose() are aliases of fwrite() and fclose(), respectively. Otherwise, this is apparently misleading. ------------------------------------------------------------------------ [2016-01-01 22:04:56] salsi at icosaedro dot it My thoughs: - Looking at source code, bzflush() simply calls fflush(). But this does not means all the data sent to the file with bzwrite() have been really written to disk: some are still in memory, where BZIP2 is building the current block of compressed data; some others are in internal buffer of the kernel, waiting to either complete a whole disk block or a file close. - The original poster encountered a problem because he missed to close the stream with bzclose() and it made instead a fflush(). Then, writing only few bytes of data, this means nothing had really written to disk, and the following read failed returning an empty string. - If the original poster had checked with bzerrno() or bzstrerr() the actual success of the bzread() operation, the result would be an "UNEXPECTED_EOF", indicating that something went wrong. This to stress how important (an difficult) may be to check errors properly, and how important and urgent may be to switch to exceptions everywhere as soon as possible :-) - Finally, there is no bug here, and in my opinion this report should be closed as "not a bug". ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=70819 -- Edit this bug report at https://bugs.php.net/bug.php?id=70819&edit=1

« previous php.doc.bugs (#18240) next »