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.
This commit is contained in:
Sara Golemon 2006-03-26 04:40:11 +00:00
parent c254b21cca
commit a64789a452
2 changed files with 10 additions and 4 deletions

2
NEWS
View File

@ -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)

View 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);