Skip to content

Catch mysqli_sql_exception from mysqli::begin_transaction()#7276

Merged
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:mysqli-begin-transaction
Jan 18, 2026
Merged

Catch mysqli_sql_exception from mysqli::begin_transaction()#7276
morozov merged 1 commit intodoctrine:4.4.xfrom
morozov:mysqli-begin-transaction

Conversation

@morozov
Copy link
Copy Markdown
Member

@morozov morozov commented Jan 18, 2026

The existing test started failing with the releases of PHP 8.5.2, PHP 8.4.17 and PHP 8.3.30 (php/php-src@dbf56e0) (example):

1) Doctrine\DBAL\Tests\Functional\TransactionTest::testBeginTransactionFailure
Failed asserting that exception of type "mysqli_sql_exception" matches expected exception "Doctrine\DBAL\Exception\ConnectionLost". Message was: "MySQL server has gone away" at
/home/runner/work/dbal/dbal/src/Driver/Mysqli/Connection.php:83
/home/runner/work/dbal/dbal/src/Connection.php:1058
/home/runner/work/dbal/dbal/tests/Functional/TransactionTest.php:29
/home/runner/work/dbal/dbal/tests/Functional/TransactionTest.php:88
/home/runner/work/dbal/dbal/tests/Functional/TransactionTest.php:28

The proposed logic is consistent with commit() and rollBack(), however I don't know if handling the return value is still needed.

UPD: starting PHP 8.1.0, the default mysqli error reporting mode is MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT (documentation), which means throwing a mysqli_sql_exception for errors from mysqli function calls (documentation).

Since we require PHP ~8.2, it means that we no longer need to check the return value. The code could be cleaned up in the next minor release.

@morozov morozov merged commit 9e5a20c into doctrine:4.4.x Jan 18, 2026
136 checks passed
@morozov morozov deleted the mysqli-begin-transaction branch January 18, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants