Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Clear mysql error in fetch_into
This commit is contained in:
Kamil Tekiela 2024-05-17 13:12:13 +02:00
commit 05efcc245e
No known key found for this signature in database
GPG key ID: 0760BDAB1E89A1E3
4 changed files with 43 additions and 1 deletions

4
NEWS
View file

@ -35,6 +35,10 @@ PHP NEWS
. Fixed build regression on systems without C++17 compilers. (Calvin Buckley, . Fixed build regression on systems without C++17 compilers. (Calvin Buckley,
Peter Kokot) Peter Kokot)
- MySQLnd:
. Fix bug GH-14255 (mysqli_fetch_assoc reports error from
nested query). (Kamil Tekiela)
- Opcache: - Opcache:
. Fixed bug GH-14109 (Fix accidental persisting of internal class constant in . Fixed bug GH-14109 (Fix accidental persisting of internal class constant in
shm). (ilutov) shm). (ilutov)

View file

@ -731,7 +731,7 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend
/* TODO: We don't have access to the connection object at this point, so we use low-level /* TODO: We don't have access to the connection object at this point, so we use low-level
* mysqlnd APIs to access the error information. We should try to pass through the connection * mysqlnd APIs to access the error information. We should try to pass through the connection
* object instead. */ * object instead. */
if (MyG(report_mode) & MYSQLI_REPORT_ERROR) { if (MyG(report_mode) & MYSQLI_REPORT_ERROR && result->conn) {
MYSQLND_CONN_DATA *conn = result->conn; MYSQLND_CONN_DATA *conn = result->conn;
unsigned error_no = conn->m->get_error_no(conn); unsigned error_no = conn->m->get_error_no(conn);
if (error_no) { if (error_no) {

View file

@ -0,0 +1,31 @@
--TEST--
Bug GH-14255 (mysqli_fetch_assoc reports error from nested query)
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
?>
--FILE--
<?php
require_once 'connect.inc';
mysqli_report(MYSQLI_REPORT_STRICT|MYSQLI_REPORT_ERROR);
$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$ca = $mysqli->query('SELECT 1 ');
$c = $ca->fetch_assoc();
try {
$mysqli->query('SELECT non_existent_column');
} catch (Exception $e) {
echo "Caught exception"."\n";
}
$c = $ca->fetch_assoc();
print "done!";
?>
--EXPECTF--
Caught exception
done!

View file

@ -970,6 +970,13 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned int
bool fetched_anything; bool fetched_anything;
zval *row_data; zval *row_data;
// We clean the error here because in unbuffered mode we could receive a new error
// and therefore consumers of this method are checking for errors
MYSQLND_CONN_DATA *conn = result->conn;
if (conn) {
SET_EMPTY_ERROR(conn->error_info);
}
DBG_ENTER("mysqlnd_res::fetch_into"); DBG_ENTER("mysqlnd_res::fetch_into");
if (FAIL == result->m.fetch_row(result, &row_data, flags, &fetched_anything)) { if (FAIL == result->m.fetch_row(result, &row_data, flags, &fetched_anything)) {
RETVAL_FALSE; RETVAL_FALSE;