From 84a6e675af9c1cf74c17f06aeca84cca358e064b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 17 Oct 2025 14:49:26 +0100 Subject: [PATCH 1/2] Handle errors in mysqli_begin_transaction --- ext/mysqli/mysqli_nonapi.c | 3 ++ .../tests/mysqli_begin_transaction_error.phpt | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 ext/mysqli/tests/mysqli_begin_transaction_error.phpt diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index 406d928699784..1f971d000fafa 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -1022,6 +1022,7 @@ PHP_FUNCTION(mysqli_begin_transaction) } if (FAIL == mysqlnd_begin_transaction(mysql->mysql, flags, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; @@ -1046,6 +1047,7 @@ PHP_FUNCTION(mysqli_savepoint) } if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; @@ -1069,6 +1071,7 @@ PHP_FUNCTION(mysqli_release_savepoint) RETURN_THROWS(); } if (FAIL == mysqlnd_release_savepoint(mysql->mysql, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; diff --git a/ext/mysqli/tests/mysqli_begin_transaction_error.phpt b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt new file mode 100644 index 0000000000000..34071d280884f --- /dev/null +++ b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +mysqli_begin_transaction() +--EXTENSIONS-- +mysqli +--SKIPIF-- +errno, $link->error)); +?> +--FILE-- + +--CLEAN-- + +--EXPECT-- +NULL +Expecting an exception. +done! From c4adcbe582faa263f11404ac89eb2cb80f2bdbca Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 17 Oct 2025 15:32:14 +0100 Subject: [PATCH 2/2] Add NEWS --- NEWS | 3 +++ ext/mysqli/tests/mysqli_begin_transaction_error.phpt | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 376139b086feb..9ba18d3fdb096 100644 --- a/NEWS +++ b/NEWS @@ -48,6 +48,9 @@ PHP NEWS - MBString: . Fixed bug GH-17112 (Macro redefinitions). (nielsdos, cmb) +- mysqli: + . Make mysqli_begin_transaction() report errors properly. (Kamil Tekiela) + - Opcache: . opcache_get_configuration() properly reports jit_prof_threshold. (cmb) diff --git a/ext/mysqli/tests/mysqli_begin_transaction_error.phpt b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt index 34071d280884f..e4d63f366e86b 100644 --- a/ext/mysqli/tests/mysqli_begin_transaction_error.phpt +++ b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt @@ -38,6 +38,5 @@ echo "done!\n"; require_once 'clean_table.inc'; ?> --EXPECT-- -NULL Expecting an exception. done!