-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implemented FR #55716 - Add an option to pass a custom stream context #1204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &url, &url_len, &format) == FAILURE) { | ||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lr", &url, &url_len, &format, &zcontext) == FAILURE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use s|lr!
here to allow passing null
. Otherwise the change looks great :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, updated the PR with that.
d2742a6
to
b9b0d3d
Compare
php_stream *stream; | ||
zval *prev_val, *hdr = NULL, *h; | ||
HashTable *hashT; | ||
zend_long format = 0; | ||
zval *zcontext = NULL; | ||
php_stream_context *context = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unnecessary to set it to NULL, since context will be always assigned below..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but we do the same in file_get_contents, so I thought I would follow suit:
http://lxr.php.net/xref/PHP_TRUNK/ext/standard/file.c#527
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then it should also be improved..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"improved", since compiler is smart enough to optimize it anyway..
That would have been a welcome improvement for PHP 7.0. Maybe we can get it in for PHP 7.1? :) |
yeah. I wasn't sure if it needs an rfc or not then I took the feature freeze seriously. |
the current way of setting the context options through stream_context_set_default is really clunky (and can cause side-effects as it modifies the global context options obviously).