Skip to content

Commit abacd91

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

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
@@ -331,14 +331,10 @@ Warning: mysqli_rollback(): (%s/%d): Commands out of sync; you can't run this co
331331

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

334-
Warning: mysqli_next_result(): (%s/%d): Commands out of sync; you can't run this command now in %s on line %d
335-
336334
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
337335

338336
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
339337

340-
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
341-
342338
Warning: mysqli_stmt_attr_set(): (%s/%d): Not implemented in %s on line %d
343339
mysqli_kill(): Argument #2 ($process_id) must be greater than 0
344340

ext/mysqlnd/mysqlnd_connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,13 +1465,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, next_result)(MYSQLND_CONN_DATA * const conn)
14651465
DBG_ENTER("mysqlnd_conn_data::next_result");
14661466
DBG_INF_FMT("conn=%" PRIu64 "", conn->thread_id);
14671467

1468+
SET_EMPTY_ERROR(conn->error_info);
1469+
14681470
if (PASS == conn->m->local_tx_start(conn, this_func)) {
14691471
do {
14701472
if (GET_CONNECTION_STATE(&conn->state) != CONN_NEXT_RESULT_PENDING) {
14711473
break;
14721474
}
14731475

1474-
SET_EMPTY_ERROR(conn->error_info);
14751476
UPSERT_STATUS_SET_AFFECTED_ROWS_TO_ERROR(conn->upsert_status);
14761477
/*
14771478
We are sure that there is a result set, since conn->state is set accordingly

0 commit comments

Comments
 (0)