ID: 42468 Updated by: [EMAIL PROTECTED] Reported By: daan at react dot nl -Status: Assigned +Status: Closed Bug Type: Streams related Operating System: * PHP Version: 5.2CVS-2007-08-29 Assigned To: iliaa New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2007-08-30 03:19:12] crrodriguez at suse dot de Index: ext/standard/file.c =================================================================== RCS file: /repository/php-src/ext/standard/file.c,v retrieving revision 1.409.2.6.2.26 diff -u -p -r1.409.2.6.2.26 file.c --- ext/standard/file.c 12 Aug 2007 17:09:59 -0000 1.409.2.6.2.26 +++ ext/standard/file.c 30 Aug 2007 03:16:42 -0000 @@ -610,6 +610,14 @@ PHP_FUNCTION(file_put_contents) RETURN_FALSE; } + if(flags & LOCK_EX && !php_stream_supports_lock(stream)) { + php_stream_wrapper *wrapper; + wrapper = php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s does not support locking", ((wrapper && wrapper->wops->label) ? wrapper->wops->label : "Wrapper")); + php_stream_close(stream); + RETURN_FALSE; + } + if (flags & LOCK_EX && php_stream_lock(stream, LOCK_EX)) { php_stream_close(stream); RETURN_FALSE; ------------------------------------------------------------------------ [2007-08-29 12:05:51] daan at react dot nl Ah it does not say so anywhere in the streams documentation that locking is (or is not) supported - or is this tied in with one of the stream attributes as listed on http://php.net/manual/en/wrappers.compression.php ? ------------------------------------------------------------------------ [2007-08-29 11:46:18] [EMAIL PROTECTED] Ilia, this should output an error when a wrapper does not support setting options. You shouldn't try locking if a wrapper doesn't support it. ------------------------------------------------------------------------ [2007-08-29 11:03:11] daan at react dot nl Description: ------------ When using the LOCK_EX flag for the file_put_contents function, and the filename is a compression stream, no data is written. Conversely, it does work when the flag is not added, or when no compression is used. Reproduce code: --------------- <?php file_put_contents('compress.zlib://test.txt', 'blabla', LOCK_EX); var_dump(file_get_contents('compress.zlib://test.txt')); Expected result: ---------------- The string 'blabla' Actual result: -------------- An empty string ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42468&edit=1