Skip to content

Commit fcabe69

Browse files
committed
Fixed bug #81494
Use the proper error reporting mechanism rather than throwing a warning. This requires something of a hack because we don't have direct access to the connection object at this point.
1 parent 9733d49 commit fcabe69

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.26
44

5+
- MySQLi:
6+
. Fixed bug #81494 (Stopped unbuffered query does not throw error). (Nikita)
7+
58
- Streams:
69
. Fixed bug #54340 (Memory corruption with user_filter). (Nikita)
710

ext/mysqli/mysqli.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,17 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend
12021202
}
12031203
#else
12041204
mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
1205+
/* TODO: We don't have access to the connection object at this point, so we use low-level
1206+
* mysqlnd APIs to access the error information. We should try to pass through the connection
1207+
* object instead. */
1208+
if (MyG(report_mode) & MYSQLI_REPORT_ERROR) {
1209+
MYSQLND_CONN_DATA *conn = result->conn;
1210+
unsigned error_no = conn->m->get_error_no(conn);
1211+
if (error_no) {
1212+
php_mysqli_report_error(
1213+
conn->m->get_sqlstate(conn), error_no, conn->m->get_error_str(conn));
1214+
}
1215+
}
12051216
#endif
12061217
}
12071218
/* }}} */

ext/mysqli/tests/bug64726.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ require_once('skipifconnectfailure.inc');
1414
require 'connect.inc';
1515
$db = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
1616

17+
mysqli_report(MYSQLI_REPORT_ERROR);
1718
$result = $db->query('SELECT 1', MYSQLI_USE_RESULT);
1819
$db->close();
1920
var_dump($result->fetch_object());
2021
?>
2122
--EXPECTF--
22-
Warning: mysqli_result::fetch_object(): Error while reading a row in %sbug64726.php on line %d
23+
Warning: mysqli_result::fetch_object(): (HY000/2014): Commands out of sync; you can't run this command now in %s on line %d
2324
bool(false)

ext/mysqli/tests/bug79375.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,4 @@ Lock wait timeout exceeded; try restarting transaction
167167
Running query on first connection
168168
Got 1 for first connection
169169
Running query on second connection
170-
171-
Warning: mysqli_result::fetch_row(): Error while reading a row in %s on line %d
172-
Got 0 for second connection
170+
Lock wait timeout exceeded; try restarting transaction

ext/mysqlnd/mysqlnd_result.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,6 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned int
17531753
}
17541754
array_init_size(return_value, array_size);
17551755
if (FAIL == result->m.fetch_row(result, (void *)return_value, flags, &fetched_anything)) {
1756-
php_error_docref(NULL, E_WARNING, "Error while reading a row");
17571756
zend_array_destroy(Z_ARR_P(return_value));
17581757
RETVAL_FALSE;
17591758
} else if (fetched_anything == FALSE) {

0 commit comments

Comments
 (0)