summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--main/streams/userspace.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index a5f496e2b8..2f60f090aa 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ PHP NEWS
. "mail.force_extra_paramaters". (Derick)
- Improved streams support: (Wez)
+ . Added context property to userspace streams object. (sara)
. stream_socket_client() - similar to fsockopen(), but more powerful.
. stream_socket_server() - Creates a server socket.
. stream_socket_accept() - Accept a client connection.
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 9b1f9418c8..7ef9a0bcac 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -185,6 +185,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
zval **args[4];
int call_result;
php_stream *stream = NULL;
+ zval *zcontext = NULL;
/* Try to catch bad usage without preventing flexibility */
if (FG(user_stream_current_filename) != NULL && strcmp(filename, FG(user_stream_current_filename)) == 0) {
@@ -201,6 +202,17 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, char *filena
object_init_ex(us->object, uwrap->ce);
ZVAL_REFCOUNT(us->object) = 1;
PZVAL_IS_REF(us->object) = 1;
+
+ if (context) {
+ MAKE_STD_ZVAL(zcontext);
+ php_stream_context_to_zval(context, zcontext);
+ add_property_zval(us->object, "context", zcontext);
+ /* The object property should be the only reference,
+ 'get rid' of our local reference. */
+ zval_ptr_dtor(&zcontext);
+ } else {
+ add_property_null(us->object, "context");
+ }
/* call it's stream_open method - set up params first */
MAKE_STD_ZVAL(zfilename);