summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-05-06 15:06:34 +0200
committerAnatol Belski <ab@php.net>2017-05-06 15:06:34 +0200
commit561f1afe6ec3e1c551dba657a77ad948065c5e95 (patch)
tree3d7733c1f79aaed2d280984d4a1172700aafc316
parent622dc2a611257c6815d167248293d4e621810b46 (diff)
downloadphp-git-561f1afe6ec3e1c551dba657a77ad948065c5e95.tar.gz
Fixed bug #74547 mysqli::change_user() doesn't accept null as $database argument w/strict_types
-rw-r--r--ext/mysqli/mysqli_api.c2
-rw-r--r--ext/mysqli/tests/bug74547.phpt25
2 files changed, 26 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 244ed945de..ffdcdaf140 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -619,7 +619,7 @@ PHP_FUNCTION(mysqli_change_user)
const CHARSET_INFO * old_charset;
#endif
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osss", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osss!", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
return;
}
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
diff --git a/ext/mysqli/tests/bug74547.phpt b/ext/mysqli/tests/bug74547.phpt
new file mode 100644
index 0000000000..a771c9a852
--- /dev/null
+++ b/ext/mysqli/tests/bug74547.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #74547 mysqli::change_user() doesn't accept null as $database argument w/strict_types
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ declare(strict_types=1);
+
+ require_once("connect.inc");
+
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ var_dump(mysqli_change_user($link, $user, $passwd, NULL));
+
+ mysqli_close($link);
+?>
+===DONE===
+--EXPECTF--
+bool(true)
+===DONE===