|
|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-29 11:03 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
|
All rights reserved. |
Last updated: Fri Nov 07 03:00:01 2025 UTC |
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;