com php-src: Fixed bug #74547 mysqli::change_user() doesn't accept null as $database argument w/ strict_types: ext/mysqli/mysqli_api.c ext/mysqli/te sts/bug74547.phpt

[email protected] (Anatol Belski)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    561f1afe6ec3e1c551dba657a77ad948065c5e95
Author:    Anatol Belski <[email protected]>         Sat, 6 May 2017 15:06:34 +0200
Parents:   622dc2a611257c6815d167248293d4e621810b46
Branches:  PHP-7.0 PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=561f1afe6ec3e1c551dba657a77ad948065c5e95

Log:
Fixed bug #74547 mysqli::change_user() doesn't accept null as $database argument w/strict_types

Bugs:
https://bugs.php.net/74547

Changed paths:
  M  ext/mysqli/mysqli_api.c
  A  ext/mysqli/tests/bug74547.phpt


Diff:
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 244ed94..ffdcdaf 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 0000000..a771c9a
--- /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===
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.