-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix UNKNOWN default values in ext/odbc #6154
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
dcc7ff1
to
348123d
Compare
575e372
to
4533257
Compare
AppVeyor failures are legitimate. |
4533257
to
abc0a50
Compare
The last 3 parameters of PS: |
@cmb69 Thanks for the info! I'll give this PR a try sooner or later! :) |
0ecddba
to
93994ac
Compare
@cmb69 And the changes you suggested worked :) |
@cmb69 above says:
The changes look reasonable to me, but I'm not familiar with the underlying APIs, so can't say whether the removed argument count restrictions make sense. |
I'm trying to figure out how these APIs are supposed to be used. Looks pretty arcane to me. Anyway, just noticed that Lines 1269 to 1271 in 9623756
php-src/ext/odbc/odbc.stub.php Line 27 in 9623756
|
Not unrelated: https://bugs.php.net/bug.php?id=78470. And sorry for hi-jacking this PR, @kocsismate! |
I think this was later clarified by @cmb69 in the P.S. paragraph. Or did I mistunderstand that the
Absolutely no problem :) |
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 for working on this! Looks good to me, but see my comments.
Regarding odbc_tables()
etc.: the null
default values are actually more close to what we had in PHP 7, so these are fine (not sure if there'd be a difference to passing empty strings, but using null
might still be useful conceptionally).
Regarding Nikita's comment: that is about odbc_procedures()
and odbc_procedurecolumns()
which formerly required 1 or 4/5 parameters. It seems to be fine to pass any number of arguments, though; basically, these functions are the pendant of odbc_tables()
and odbc_tablecolumns()
, respectively, and these functions already supported that.
ext/odbc/php_odbc.c
Outdated
@@ -964,7 +964,7 @@ PHP_FUNCTION(odbc_prepare) | |||
PHP_FUNCTION(odbc_execute) | |||
{ | |||
zval *pv_res, *tmp; | |||
HashTable *pv_param_ht; | |||
HashTable *pv_param_ht = 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.
HashTable *pv_param_ht = NULL; | |
HashTable *pv_param_ht = (HashTable *) &zend_empty_array; |
This way we could drop the check for !pv_param_ht
below, and it also looks cleaner wrt. having []
as default.
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.
oh, nice!
@@ -31,14 +31,14 @@ function odbc_data_source($connection_id, int $fetch_type): array|false {} | |||
* @param resource $connection_id | |||
* @return resource|false | |||
*/ | |||
function odbc_exec($connection_id, string $query, int $flags = UNKNOWN) {} | |||
function odbc_exec($connection_id, string $query) {} |
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 agree that it makes sense to drop this unused parameter, but there should be a note about that in UPGRADING.
ext/odbc/php_odbc.c
Outdated
@@ -974,26 +974,20 @@ PHP_FUNCTION(odbc_execute) | |||
unsigned char otype; | |||
SQLSMALLINT ctype; | |||
odbc_result *result; | |||
int numArgs = ZEND_NUM_ARGS(), i, ne; | |||
int i, ne = 0; |
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.
The initialization appears to be superfluous, but doesn't hurt.
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 sure why I added it. So I'll get rid of it.
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.
Oh, it has just come to my mind: since the !pv_param_ht
check below would short-circuit the initialization of ne
in the next condition, I had to assign it a default value, because it's used inside the "then" branch.
it's not the case anymore, so I can safely get rid of it for sure.
UPDATE: I've just rebased to master + pushed a new commit
93994ac
to
26811b2
Compare
…ion signature > The unused flags parameter of `odbc_exec()` has been removed. Note: per the commit, this also applies to the `odbc_do()` alias of `odbc_exec()`. Refs: * https://github.com/php/php-src/blob/0a84fba0deb1c1b75770a436c4236dc56e6d0463/UPGRADING#L400 * php/php-src#6154 * php/php-src@9b50fd2
No description provided.