Bug #75776 [Ver]: compression filters on stdout not working any more

From: Date: Mon, 15 Feb 2021 14:08:49 +0000
Subject: Bug #75776 [Ver]: compression filters on stdout not working any more
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232170@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75776&edit=1 ID: 75776 Updated by: cmb@php.net Reported by: shestero at meta dot ua Summary: compression filters on stdout not working any more Status: Verified Type: Bug -Package: *Compression related +Package: Streams related Operating System: Debian PHP Version: 7.0.27 Block user comment: N Private report: N New Comment: With regard to zlib.deflate this is a duplicate of bug #48725, which is fixed as of PHP 7.4.14 and 8.0.1, respectively, but apparently bzip2.compress has the same problem. Recatogorizing as "streams related" since "filter related" is used too often for ext/filter. Previous Comments: ------------------------------------------------------------------------ [2018-01-10 02:09:27] shestero at meta dot ua Commenting fflush solves the problem. I checked. ------------------------------------------------------------------------ [2018-01-10 02:08:28] shestero at meta dot ua Yes. Really commenting fflush solves the problem? But what's wrong with fflush? I process data streaming and sometimes fill it should be flushed after some portion is over. ------------------------------------------------------------------------ [2018-01-09 14:37:21] mike@php.net Seems to be caused by the fflush() call. ------------------------------------------------------------------------ [2018-01-08 03:30:09] shestero at meta dot ua PS fwrite($bz,"sdfgdfg"); // output such way ... fflush($bz); fclose($bz); of cause at the end. The existing code used about 5-6 years with different PHP versions so I'm quite sure it's ok. ------------------------------------------------------------------------ [2018-01-08 03:27:13] shestero at meta dot ua Description: ------------ I used this way to produce compressed output for years but now it return zero-output without any errors anywhere. Registered Stream Filters: zlib.*, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk My configure parameters: './configure' '--with-openssl' '--with-ssl=/usr/bin/openssl' '--with-ssl-lib=/usr/lib/x86_64-linux-gnu' '--with-libdir=lib/x86_64-linux-gnu' '--with-bz2' '--enable-exif' '--with-gd' '--with-mcrypt' '--with-mysql' '--with-mysql-sock' '--enable-sockets' '--enable-zip' '--with-apxs2=/usr/bin/apxs2' '--with-config-file-path=/var/lib/apache2/conf' '--with-jpeg-dir' '--enable-gd-native-ttf' '--with-xmlrpc' '--with-freetype-dir' '--with-zlib' '--with-zlib-dir' '--enable-maintainer-zts' '--with-tsrm-pthreads' '--with-mysqli' '--enable-mbstring' '--with-pdo-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-curl' '--enable-memcache' PS Output mute as I adding compression filters. string.toupper and string.tolower work! Test script: --------------- error_reporting(E_ALL); ini_set("display_errors", 1); if (true) { header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=main.csv.bz2"); header("Content-Type: application/x-bzip2"); header("Content-Transfer-Encoding: binary"); } else { header("Content-Type: application/csv"); header("Content-Disposition: attachment;Filename=main.csv"); } $bz = fopen('php://output', 'w'); fwrite($bz,"sdfgdfg"); // output such way ... fflush($bz); fclose($bz); stream_filter_append($bz, 'convert.iconv.UTF-8/CP1251//TRANSLIT'); // ok if (true) { $param = array('blocks' => 6, 'work' => 0); // for bzip2 $ok = stream_filter_append($bz, 'bzip2.compress', STREAM_FILTER_WRITE, $param); // $param = array('level' => 6, 'window' => 15, 'memory' => 9); // for gzip //$ok = stream_filter_append($bz, 'zlib.deflate');//, STREAM_FILTER_WRITE, $param); if ($ok===false) { die("Cannot stream_filter_append( 'bzip2.compress' ) !"); } } Expected result: ---------------- error or some output as usual Actual result: -------------- browser saves zero-size file. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75776&edit=1

« previous php.bugs (#232170) next »