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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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' => '']);
|
||||
|
Reference in New Issue
Block a user