Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions ext/mysqli/mysqli_nonapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
42 changes: 42 additions & 0 deletions ext/mysqli/tests/mysqli_begin_transaction_error.phpt
Original file line number Diff line number Diff line change
@@ -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!
Loading