From: david at acz dot org
Operating system: SLES 10 x86_64
PHP version: 5.2.5
PHP Bug Type: Streams related
Bug description: file_put_contents writes empty file with zlib and LOCK_EX
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) ""
--
Edit bug report at http://bugs.php.net/?id=44501&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44501&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44501&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44501&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44501&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44501&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44501&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44501&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44501&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44501&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44501&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44501&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44501&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44501&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44501&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44501&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44501&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44501&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44501&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44501&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44501&r=mysqlcfg