From: Sara Golemon Date: Sun, 26 Mar 2006 04:40:11 +0000 (+0000) Subject: Expand stream_context_create() to allow specifying params X-Git-Tag: RELEASE_1_3~256 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a64789a4525f3946d619097bb059ace8cdf7e1f4;p=php Expand stream_context_create() to allow specifying params 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. --- diff --git a/NEWS b/NEWS index 8d437858c7..265e986573 100644 --- 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) diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index abdf00a0f2..a7c5323931 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -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", ¶ms) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!a!", &options, ¶ms) == 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);