Skip to content

Commit 14f1743

Browse files
committed
修复在特定情况 PDO 捕获异常做离线检测 errorInfo 为 null 时的错误 (#576)
1 parent 3eaf65a commit 14f1743

File tree

1 file changed

+7
-7
lines changed
  • src/Components/pgsql/src/Db/Drivers/PdoPgsql

1 file changed

+7
-7
lines changed

src/Components/pgsql/src/Db/Drivers/PdoPgsql/Driver.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function ping(): bool
124124
}
125125
catch (\PDOException $e)
126126
{
127-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
127+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
128128
{
129129
$this->close();
130130
}
@@ -189,7 +189,7 @@ public function beginTransaction(): bool
189189
}
190190
catch (\PDOException $e)
191191
{
192-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
192+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
193193
{
194194
$this->close();
195195
}
@@ -219,7 +219,7 @@ public function commit(): bool
219219
}
220220
catch (\PDOException $e)
221221
{
222-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
222+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
223223
{
224224
$this->close();
225225
}
@@ -242,7 +242,7 @@ public function rollBack(?int $levels = null): bool
242242
}
243243
catch (\PDOException $e)
244244
{
245-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
245+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
246246
{
247247
$this->close();
248248
}
@@ -351,7 +351,7 @@ public function exec(string $sql): int
351351
}
352352
catch (\PDOException $e)
353353
{
354-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
354+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
355355
{
356356
$this->close();
357357
}
@@ -443,7 +443,7 @@ public function prepare(string $sql, array $driverOptions = []): IPgsqlStatement
443443
}
444444
catch (\PDOException $e)
445445
{
446-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
446+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
447447
{
448448
$this->close();
449449
}
@@ -476,7 +476,7 @@ public function query(string $sql): IPgsqlStatement
476476
}
477477
catch (\PDOException $e)
478478
{
479-
if ($this->checkCodeIsOffline($e->errorInfo[0]))
479+
if (isset($e->errorInfo[0]) && $this->checkCodeIsOffline($e->errorInfo[0]))
480480
{
481481
$this->close();
482482
}

0 commit comments

Comments
 (0)