]> granicus.if.org Git - php/commitdiff
Expand stream_context_create() to allow specifying params
authorSara Golemon <pollita@php.net>
Sun, 26 Mar 2006 04:40:11 +0000 (04:40 +0000)
committerSara Golemon <pollita@php.net>
Sun, 26 Mar 2006 04:40:11 +0000 (04:40 +0000)
as well as options.  Ignore the internal name change of the first arg.
The first arg is still for options, the second arg is for actual params.

NEWS
ext/standard/streamsfuncs.c

diff --git a/NEWS b/NEWS
index 8d437858c707ee535669f6a534ecf4b2883e0c09..265e9865731b72b3406a617f80666098189afbd9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,8 @@ PHP                                                                        NEWS
   the part of haystack before or after first occurence of needle. (Johannes)
 - Added possibility to check in which extension an internal function was
   defined using reflection API. (Johannes)
+- Added second optional parameter to stream_context_create() to set params
+  during context creation. (Sara)
 - Fixed bug #36840 (Memory leak if cast operator throws an exception that is
   caught). (Dmitry)
 - Fixed bug #36630 (umask not reset at the end of the request). (Ilia)
index abdf00a0f2b8c01bb8d7d44771c7f8e19cd94bcb..a7c53239317ae0b841979c141a4554763db3b69d 100644 (file)
@@ -1103,21 +1103,25 @@ PHP_FUNCTION(stream_context_get_default)
 }
 /* }}} */
 
-/* {{{ proto resource stream_context_create([array options])
+/* {{{ proto resource stream_context_create([array options[, array params]])
    Create a file context and optionally set parameters */
 PHP_FUNCTION(stream_context_create)
 {
-       zval *params = NULL;
+       zval *options = NULL, *params = NULL;
        php_stream_context *context;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a", &params) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &options, &params) == FAILURE) {
                RETURN_FALSE;
        }
        
        context = php_stream_context_alloc();
        
+       if (options) {
+               parse_context_options(context, options TSRMLS_CC);
+       }
+
        if (params) {
-               parse_context_options(context, params TSRMLS_CC);
+               parse_context_params(context, params TSRMLS_CC);
        }
        
        php_stream_context_to_zval(context, return_value);