|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-04-12 17:49 UTC] tessus@php.net
Description:
------------
I've tested it with PHP 7.4.15 and PHP 7.4.16.
I get errors with zlib related functions. e.g. for the test script below, I get the following warning, which should be an error in the first place, because the resulting file is invalid.
PHP Warning: gzencode(): stream error in t.php on line 3
It happens with cli and php-fpm. I do have read/write access to the directory where the file bigfile.txt is located.
I've tested this with 7.3.27 and it works without issues. I compile PHP myself and there were no errors in config.log, nor during compilation. configure stated for both PHP releases that zlib was found and ok to use.
Test script:
---------------
<?php
$data = implode("", file("bigfile.txt"));
$gzdata = gzencode($data, 9);
$fp = fopen("bigfile.txt.gz", "w");
fwrite($fp, $gzdata);
fclose($fp);
?>
Expected result:
----------------
The file should be compressed and the result should be a valid bigfile.txt.gz
Actual result:
--------------
A file bigfile.txt.gz is created with 0 bytes.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 05:00:01 2025 UTC |
> zlib_version() tells me undefined function in the php shell. Oh indeed, the proper spelling is zlibVersion(), and that function is used to retrieve the linked version[1]. To my knowlege, PHP does not (and never did) bundle zlib, so this old version must be somewhere on your system. I assume that the difference between PHP 7.3 and 7.4 is due to build system changes; 7.4 uses pkg-config to detect zlib[2] while 7.3 manually searched for the lib in the usual places[3]. Anyhow, what does pkg-config --print-provides zlib report? [1] <https://github.com/php/php-src/blob/php-7.4.16/ext/zlib/zlib.c#L1593> [2] <https://github.com/php/php-src/blob/php-7.4.16/ext/zlib/config0.m4> [3] <https://github.com/php/php-src/blob/php-7.3.27/ext/zlib/config0.m4>