From: Nikita Popov Date: Wed, 5 Jun 2019 09:26:20 +0000 (+0200) Subject: Make mysqli_connect arguments explicitly nullable X-Git-Tag: php-7.4.0alpha1~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9cf6a5413a563b0c174a6cb4974bfd0795ce43e4;p=php 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. --- diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 3ffa8d05dd..d6c474b7f3 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) {