Skip to content

Commit 07a6ffe

Browse files
bug symfony#54305 [Cache][Lock] Identify missing table in pgsql correctly and address failing integration tests (arifszn)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Cache][Lock] Identify missing table in pgsql correctly and address failing integration tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? |no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | | License | MIT ## Description The existing code snippet is as follows: ```php $code = $exception->errorInfo ? $exception->errorInfo[1] : $exception->getCode(); switch (true) { case 'pgsql' === $driver && '42P01' === $code: ``` When we print `$exception->errorInfo[1]`, it yields 7, which is interpreted as false. This behavior has been rectified. ![image](https://github.com/symfony/symfony/assets/45073703/3f928fcb-ba1c-4113-a0d9-b4d04a19bc70) **Additionally, this pull request fixes the integration tests that have been failing persistently until now.** ![image](https://github.com/symfony/symfony/assets/45073703/050fe625-4ff6-423d-9c89-ed183f36e670) Commits ------- 98fe71a [Cache][Lock] Identify missing table in pgsql correctly and address failing integration tests
2 parents cb3ec06 + 98fe71a commit 07a6ffe

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,10 +600,10 @@ private function getServerVersion(): string
600600
private function isTableMissing(\PDOException $exception): bool
601601
{
602602
$driver = $this->driver;
603-
$code = $exception->errorInfo ? $exception->errorInfo[1] : $exception->getCode();
603+
[$sqlState, $code] = $exception->errorInfo ?? [null, $exception->getCode()];
604604

605605
switch (true) {
606-
case 'pgsql' === $driver && '42P01' === $code:
606+
case 'pgsql' === $driver && '42P01' === $sqlState:
607607
case 'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'):
608608
case 'oci' === $driver && 942 === $code:
609609
case 'sqlsrv' === $driver && 208 === $code:

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,10 @@ private function getCurrentTimestampStatement(): string
330330
private function isTableMissing(\PDOException $exception): bool
331331
{
332332
$driver = $this->getDriver();
333-
$code = $exception->errorInfo ? $exception->errorInfo[1] : $exception->getCode();
333+
[$sqlState, $code] = $exception->errorInfo ?? [null, $exception->getCode()];
334334

335335
switch (true) {
336-
case 'pgsql' === $driver && '42P01' === $code:
336+
case 'pgsql' === $driver && '42P01' === $sqlState:
337337
case 'sqlite' === $driver && str_contains($exception->getMessage(), 'no such table:'):
338338
case 'oci' === $driver && 942 === $code:
339339
case 'sqlsrv' === $driver && 208 === $code:

0 commit comments

Comments
 (0)