Skip to content

Commit 65e2dbd

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Prevent mysqli::next_result from reporting errors from previous calls (#7304)
2 parents bf9afc1 + d26069a commit 65e2dbd

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
next_result reports errors from previous calls
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
12+
require_once __DIR__ . '/connect.inc';
13+
14+
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
15+
16+
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
17+
18+
try {
19+
$mysqli->query("Syntax Error");
20+
} catch (mysqli_sql_exception $e) {
21+
}
22+
$mysqli->next_result();
23+
24+
print "done!";
25+
26+
?>
27+
--EXPECTF--
28+
done!

ext/mysqli/tests/mysqli_report.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,10 @@ Warning: mysqli_rollback(): (%s/%d): Commands out of sync; you can't run this co
330330

331331
Warning: mysqli_stmt_prepare(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d
332332

333-
Warning: mysqli_next_result(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d
334-
335333
Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
336334

337335
Warning: mysqli_store_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
338336

339-
Warning: mysqli_next_result(): (%s/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
340-
341337
Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d
342338
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
343339

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, next_result)(MYSQLND_CONN_DATA * const conn)
14761476
DBG_ENTER("mysqlnd_conn_data::next_result");
14771477
DBG_INF_FMT("conn=%llu", conn->thread_id);
14781478

1479+
SET_EMPTY_ERROR(conn->error_info);
1480+
14791481
if (PASS == conn->m->local_tx_start(conn, this_func)) {
14801482
do {
14811483
if (GET_CONNECTION_STATE(&conn->state) != CONN_NEXT_RESULT_PENDING) {
14821484
break;
14831485
}
14841486

1485-
SET_EMPTY_ERROR(conn->error_info);
14861487
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
14871488
/*
14881489
We are sure that there is a result set, since conn->state is set accordingly

0 commit comments

Comments
 (0)