com php-src: Make mysqli_connect arguments explicitly n ullable: ext/mysqli/mysqli_nonapi.c
| From: | Nikita Popov | Date: | Wed, 05 Jun 2019 09:30:13 +0000 |
| Subject: | com php-src: Make mysqli_connect arguments explicitly n ullable: ext/mysqli/mysqli_nonapi.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106564@lists.php.net to get a copy of this message | ||
Commit: 9cf6a5413a563b0c174a6cb4974bfd0795ce43e4
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 5 Jun 2019 11:26:20 +0200
Parents: 8f854c109927019192721a890ed7f201db1e2f87
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9cf6a5413a563b0c174a6cb4974bfd0795ce43e4
Log:
Make mysqli_connect arguments explicitly nullable
It should be possible to skip any of these (and use the ini configured
defaults) by passing null, independently of strict_types settings.
Noticed while working on GH-4227.
Changed paths:
M ext/mysqli/mysqli_nonapi.c
Diff:
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index 3ffa8d0..d6c474b 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -58,6 +58,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
size_t hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
zend_bool persistent = FALSE;
zend_long port = 0, flags = 0;
+ zend_bool port_is_null = 1;
zend_string *hash_key = NULL;
zend_bool new_connection = FALSE;
zend_resource *le;
@@ -80,8 +81,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
hostname = username = dbname = passwd = socket = NULL;
if (!is_real_connect) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ssssls", &hostname, &hostname_len,
&username, &username_len,
- &passwd, &passwd_len, &dbname, &dbname_len, &port, &socket,
&socket_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!s!l!s!", &hostname,
&hostname_len, &username, &username_len,
+ &passwd, &passwd_len, &dbname, &dbname_len, &port, &port_is_null,
&socket, &socket_len) == FAILURE) {
return;
}
@@ -98,9 +99,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */
} else {
/* We have flags too */
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|sssslsl", &object,
mysqli_link_class_entry,
- &hostname, &hostname_len, &username, &username_len, &passwd,
&passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len,
- &flags) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s!s!s!s!l!s!l",
&object, mysqli_link_class_entry,
+ &hostname, &hostname_len, &username, &username_len, &passwd,
&passwd_len, &dbname, &dbname_len, &port, &port_is_null, &socket,
&socket_len, &flags) == FAILURE) {
return;
}
@@ -121,7 +121,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
if (!socket_len || !socket) {
socket = MyG(default_socket);
}
- if (!port){
+ if (port_is_null || !port) {
port = MyG(default_port);
}
if (!passwd) {