1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Squashed commit of the following:

commit c4adcbe582
Author: Kamil Tekiela <tekiela246@gmail.com>
Date:   Fri Oct 17 15:32:14 2025 +0100

    Add NEWS

commit 84a6e675af
Author: Kamil Tekiela <tekiela246@gmail.com>
Date:   Fri Oct 17 14:49:26 2025 +0100

    Handle errors in mysqli_begin_transaction
This commit is contained in:
Kamil Tekiela
2025-12-14 15:23:43 +00:00
parent 97a90f4361
commit dbf56e0eba
3 changed files with 49 additions and 1 deletions

5
NEWS
View File

@@ -8,7 +8,7 @@ PHP NEWS
- Bz2:
. Fixed bug GH-20620 (bzcompress overflow on large source size).
(David Carlier)
(David Carlier)
- GD:
. Fixed bug GH-20622 (imagestring/imagestringup overflow). (David Carlier)
@@ -70,6 +70,9 @@ PHP NEWS
. Fixed bug GH-20492 (mbstring compile warning due to non-strings).
(ndossche)
- mysqli:
. Make mysqli_begin_transaction() report errors properly. (Kamil Tekiela)
- MySQLnd:
. Fixed bug GH-20528 (Regression breaks mysql connexion using an IPv6 address
enclosed in square brackets). (Remi)

View File

@@ -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;

View File

@@ -0,0 +1,42 @@
--TEST--
mysqli_begin_transaction()
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once 'skipifconnectfailure.inc';
require_once 'connect.inc';
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
die(sprintf("skip Cannot connect, [%d] %s", mysqli_connect_errno(), mysqli_connect_error()));
if (!have_innodb($link))
die(sprintf("skip Needs InnoDB support, [%d] %s", $link->errno, $link->error));
?>
--FILE--
<?php
require_once 'connect.inc';
mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
try {
mysqli_query($link, sprintf('KILL %d', mysqli_thread_id($link)));
} catch (mysqli_sql_exception) {
// ignore
}
try {
mysqli_begin_transaction($link);
} catch (mysqli_sql_exception $e) {
echo "Expecting an exception.\n";
}
echo "done!\n";
?>
--CLEAN--
<?php
require_once 'clean_table.inc';
?>
--EXPECT--
Expecting an exception.
done!