|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-10-29 14:27 UTC] huisman at comandi dot nl
Description:
------------
`stream_filter_append` in combination with `zlib.deflate` no longer works as expected in PHP 7.2 and produces an empty string instead of the expected compressed string. (see test script).
Test script:
---------------
<?php
$stream = fopen('php://temp', 'w+');
fwrite($stream, 'something something');
stream_filter_append($stream, 'zlib.deflate', STREAM_FILTER_READ, ['level' => 6]);
rewind($stream);
$contents = fread($stream, 1024);
Expected result:
----------------
A compressed string
Actual result:
--------------
An empty string
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
The zlib.deflate stream filter is working as expected in these versions: 5.5.21 - 5.5.38, 5.6.5 - 7.1.33 But in these versions the zlib.deflate stream filter truncates data. 5.2.0 - 5.5.20, 5.6.0 - 5.6.4, 7.2.0 - 7.4.0 Here is another test code version: $string = str_repeat("0123456789", 100); $resource = fopen('data://text/plain,' . $string,'r'); stream_filter_append($resource, 'zlib.deflate', STREAM_FILTER_READ, 6); $compressed = stream_get_contents($resource); echo strlen($compressed); Results visible here: https://3v4l.org/OOjF4