|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-03-22 03:06 UTC] david at acz dot org
Description:
------------
When passing LOCK_EX to file_put_contents() using a "compress.zlib" stream, the function creates a valid gzip file (non-empty) containing zero un-compressed bytes (gunzip outputs nothing) and returns false.
This was reported in #42468, but wasn't actually fixed. The function needs to fail BEFORE it opens (and destroys) the output file.
Reproduce code:
---------------
<?
$name = "/tmp/hello.txt.gz";
$file = "compress.zlib://" . $name;
var_dump(file_put_contents($file, "hello", LOCK_EX));
var_dump(filesize($name));
var_dump(file_get_contents($file));
?>
Expected result:
----------------
int(5)
int(31)
string(5) "hello"
Actual result:
--------------
bool(false)
int(26)
string(0) ""
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 12:00:02 2025 UTC |
Ilia, the fix propably wasn't quite right, and I get this with the example script: [jani@localhost ~]$ /home/jani/src/build/php_5_2/sapi/cli/php t.php Warning: file_put_contents(compress.zlib:///tmp/hello.txt.gz): failed to open stream: Inappropriate ioctl for device in /home/jani/t.php on line 5 bool(false) int(0) string(0) "" /home/jani/src/php-5.2/main/streams/streams.c(390) : Stream of type 'STDIO' 0x9504c4c (path:/tmp/hello.txt.gz) was not closed [Tue Mar 25 15:30:11 2008] Script: 't.php' /home/jani/src/php-5.2/main/streams/streams.c(227) : Freeing 0x09504C4C (128 bytes), script=t.php /home/jani/src/php-5.2/ext/zlib/zlib_fopen_wrapper.c(127) : Actual location (location was relayed) === Total 1 memory leaks detected ===