Skip to content

Commit 7d3a6e7

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix mysqli_get_warnings() with multi queries
2 parents 0563dfe + 8a5bc8c commit 7d3a6e7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ext/mysqli/mysqli_nonapi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ PHP_FUNCTION(mysqli_get_warnings)
979979
MY_MYSQL *mysql;
980980
zval *mysql_link;
981981
MYSQLI_RESOURCE *mysqli_resource;
982-
MYSQLI_WARNING *w;
982+
MYSQLI_WARNING *w = NULL;
983983

984984
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_link, mysqli_link_class_entry) == FAILURE) {
985985
RETURN_THROWS();
@@ -992,7 +992,8 @@ PHP_FUNCTION(mysqli_get_warnings)
992992
#else
993993
w = php_get_warnings(mysql->mysql);
994994
#endif
995-
} else {
995+
}
996+
if (!w) {
996997
RETURN_FALSE;
997998
}
998999
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
@@ -1008,7 +1009,7 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
10081009
MY_STMT *stmt;
10091010
zval *stmt_link;
10101011
MYSQLI_RESOURCE *mysqli_resource;
1011-
MYSQLI_WARNING *w;
1012+
MYSQLI_WARNING *w = NULL;
10121013

10131014
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &stmt_link, mysqli_stmt_class_entry) == FAILURE) {
10141015
RETURN_THROWS();
@@ -1017,7 +1018,8 @@ PHP_FUNCTION(mysqli_stmt_get_warnings)
10171018

10181019
if (mysqli_stmt_warning_count(stmt->stmt)) {
10191020
w = php_get_warnings(mysqli_stmt_get_connection(stmt->stmt));
1020-
} else {
1021+
}
1022+
if (!w) {
10211023
RETURN_FALSE;
10221024
}
10231025
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));

ext/mysqli/tests/bug54221.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,5 @@ mysqli.reconnect = Off
4242
print "done!";
4343
?>
4444
--EXPECT--
45-
Warning: :
4645
Warning: 1050: Table 't54221' already exists
4746
done!

0 commit comments

Comments
 (0)