From df61b3c6ebad5b9b00ef40bb5c32de02de70d35e Mon Sep 17 00:00:00 2001 From: Jani Taskinen Date: Sat, 1 Aug 2009 03:17:31 +0000 Subject: [PATCH] - Fixed bug #43510 (stream_get_meta_data() does not return same mode as used in fopen) --- NEWS | 2 ++ ext/standard/http_fopen_wrapper.c | 3 ++- ext/standard/tests/http/bug43510.phpt | 28 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/http/bug43510.phpt diff --git a/NEWS b/NEWS index 877c8680482d7..d5c0869daba7d 100644 --- a/NEWS +++ b/NEWS @@ -75,6 +75,8 @@ PHP NEWS - Fixed bug #45141 (setcookie will output expires years of >4 digits). (Ilia) - Fixed bug #44144 (spl_autoload_functions() should return object instance when appropriate). (Hannes, Etienne) +- Fixed bug #43510 (stream_get_meta_data() does not return same mode as used + in fopen). (Jani) - Fixed bug #42434 (ImageLine w/ antialias = 1px shorter). (wojjie at gmail dot com, Kalle) diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 64981682b0c56..6a39982d3f1f3 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -325,7 +325,6 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, strlcat(scratch, " HTTP/1.0\r\n", scratch_len); } - /* send it */ php_stream_write(stream, scratch, strlen(scratch)); @@ -756,6 +755,8 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, * the stream */ stream->position = 0; + /* restore mode */ + strlcpy(stream->mode, mode, sizeof(stream->mode)); } return stream; diff --git a/ext/standard/tests/http/bug43510.phpt b/ext/standard/tests/http/bug43510.phpt new file mode 100644 index 0000000000000..710b086351724 --- /dev/null +++ b/ext/standard/tests/http/bug43510.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #43510: stream_get_meta_data() does not return same mode as used in fopen +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(1) "r" +string(2) "rb"