-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Move a few custom type checks to ZPP #6034
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
735e36d
to
ed8e8d8
Compare
ed8e8d8
to
edede27
Compare
zend_string *field_str; | ||
zend_string *field_str, *pv_field_str; | ||
zend_long pv_field_long; |
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.
Quick question: moving from zval
s to zend_(string|int|etc..)
types, are they cheaper?
Also, is that a good practice to follow?
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.
@carusogabriel I don't think they are noticably cheaper. The real benefit is being able to accept arguments whose type is validated according to the standard semantics, rather than in a custom way.
d7e055e
to
fc60c36
Compare
16d3169
to
22abceb
Compare
ext/mysqli/mysqli_api.c
Outdated
} | ||
ret = mysql_options(mysql->mysql, mysql_option, (char *) &mysql_value_long); | ||
} else { | ||
ret = 1; |
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'm a bit unsure about this one. If we consider a call like mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, '100')
, this was previously valid and the '100'
was interpreted as 100
. Now it will throw instead. That is, it's now necessary to match the type of the option, rather than the option forcing the type of the value.
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, it's a valid critique against the (former) implementation. Now, I've just pushed a change which tries to address this by trying to convert the type to the expected one if necessary. I like this solution, but I'm curious whether you see any problem with this approach.
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.
Not a fan of this. This has made the implementation more complicated than it was before.
I think it is better to keep this as a mixed argument. The fact that only int|string is accepted is rather incidential imho (e.g. there's no reason why in the future an option using float or bool value couldn't be added).
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 reverted all these changes (from mysqli and xml both), but stayed with the string|int
PHPDoc type hints.
22abceb
to
0126355
Compare
9408fe8
to
7a26727
Compare
|
||
if (str_headers) { | ||
tmp_headers = zend_string_init(ZSTR_VAL(str_headers), ZSTR_LEN(str_headers), 0); | ||
MAIL_ASCIIZ_CHECK_MBSTRING(ZSTR_VAL(tmp_headers), ZSTR_LEN(tmp_headers)); |
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.
Drive-by note: I think the MAIL_ASCIIZ_CHECK_MBSTRING calls above are corrupting the argument strings :(
ext/mysqli/mysqli_api.c
Outdated
} | ||
ret = mysql_options(mysql->mysql, mysql_option, (char *) &mysql_value_long); | ||
} else { | ||
ret = 1; |
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.
Not a fan of this. This has made the implementation more complicated than it was before.
I think it is better to keep this as a mixed argument. The fact that only int|string is accepted is rather incidential imho (e.g. there's no reason why in the future an option using float or bool value couldn't be added).
44a5c7a
to
05ba96f
Compare
05ba96f
to
8b07b3e
Compare
No description provided.