1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-08 15:16:58 +02:00

MySqliDriver::getResource() fixed access to resource being closed prior to the call in PHP 8 (#410)

This commit is contained in:
Andrej Rypo
2021-12-12 03:54:42 +01:00
committed by David Grudl
parent 82150d120d
commit 7d82ce2ff6
2 changed files with 14 additions and 1 deletions

View File

@@ -253,7 +253,11 @@ class MySqliDriver implements Dibi\Driver
*/
public function getResource(): ?\mysqli
{
return @$this->connection->thread_id ? $this->connection : null;
try {
return @$this->connection->thread_id ? $this->connection : null;
} catch (\Throwable $e) {
return null;
}
}

View File

@@ -63,6 +63,15 @@ test('', function () use ($config) {
});
test('', function () use ($config) {
$conn = new Connection($config);
Assert::true($conn->isConnected());
$conn->__destruct();
Assert::false($conn->isConnected());
});
test('', function () use ($config) {
Assert::exception(function () use ($config) {
new Connection($config + ['onConnect' => '']);