iliaa Mon Nov 12 18:47:46 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/main/streams plain_wrapper.c
/php-src/ext/standard file.c
/php-src NEWS
Log:
Fixed bug #43182 (file_put_contents() LOCK_EX does not work properly on
file
http://cvs.php.net/viewvc.cgi/php-src/main/streams/plain_wrapper.c?r1=1.52.2.6.2.25&r2=1.52.2.6.2.26&diff_format=u
Index: php-src/main/streams/plain_wrapper.c
diff -u php-src/main/streams/plain_wrapper.c:1.52.2.6.2.25
php-src/main/streams/plain_wrapper.c:1.52.2.6.2.26
--- php-src/main/streams/plain_wrapper.c:1.52.2.6.2.25 Thu Nov 1 17:32:26 2007
+++ php-src/main/streams/plain_wrapper.c Mon Nov 12 18:47:46 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: plain_wrapper.c,v 1.52.2.6.2.25 2007/11/01 17:32:26 jani Exp $ */
+/* $Id: plain_wrapper.c,v 1.52.2.6.2.26 2007/11/12 18:47:46 iliaa Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -63,6 +63,9 @@
case 'x':
flags = O_CREAT|O_EXCL;
break;
+ case 'c':
+ flags = O_CREAT;
+ break;
default:
/* unknown mode */
return FAILURE;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.28&r2=1.409.2.6.2.29&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.28
php-src/ext/standard/file.c:1.409.2.6.2.29
--- php-src/ext/standard/file.c:1.409.2.6.2.28 Tue Sep 4 12:51:49 2007
+++ php-src/ext/standard/file.c Mon Nov 12 18:47:46 2007
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.409.2.6.2.28 2007/09/04 12:51:49 iliaa Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.29 2007/11/12 18:47:46 iliaa Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -592,6 +592,7 @@
zval *zcontext = NULL;
php_stream_context *context = NULL;
php_stream *srcstream = NULL;
+ char mode[3] = "wb";
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz/|lr!",
&filename, &filename_len,
&data, &flags, &zcontext) == FAILURE) {
@@ -604,8 +605,14 @@
context = php_stream_context_from_zval(zcontext, flags &
PHP_FILE_NO_DEFAULT_CONTEXT);
- stream = php_stream_open_wrapper_ex(filename, (flags & PHP_FILE_APPEND)
? "ab" : "wb",
- ((flags & PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) |
ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, context);
+ if (flags & PHP_FILE_APPEND) {
+ mode[0] = 'a';
+ } else if (flags & LOCK_EX) {
+ mode[0] = 'c';
+ }
+ mode[2] = '\0';
+
+ stream = php_stream_open_wrapper_ex(filename, mode, ((flags &
PHP_FILE_USE_INCLUDE_PATH) ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS,
NULL, context);
if (stream == NULL) {
RETURN_FALSE;
}
@@ -615,6 +622,10 @@
RETURN_FALSE;
}
+ if (mode[0] = 'c') {
+ php_stream_truncate_set_size(stream, 0);
+ }
+
switch (Z_TYPE_P(data)) {
case IS_RESOURCE:
numbytes = php_stream_copy_to_stream(srcstream, stream,
PHP_STREAM_COPY_ALL);
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1005&r2=1.2027.2.547.2.1006&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1005 php-src/NEWS:1.2027.2.547.2.1006
--- php-src/NEWS:1.2027.2.547.2.1005 Mon Nov 12 11:24:13 2007
+++ php-src/NEWS Mon Nov 12 18:47:46 2007
@@ -3,6 +3,8 @@
?? ??? 2008, PHP 5.2.6
- Fixed bug #43216 (stream_is_local() returns false on "file://"). (Dmitry)
- Fixed bug #43201 (Crash on using unitialized vals and __get/__set). (Dmitry)
+- Fixed bug #43182 (file_put_contents() LOCK_EX does not work properly on file
+ truncation). (Ilia)
- Fixed bug #43175 (__destruct() throwing an exception with __call() causes
segfault). (Dmitry)
- Fixed bug #42937 (__call() method not invoked when methods are called on
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php