8000 [FrameworkBundle][Cache] PDO-based cache pool table autocreation does not work · Issue #29898 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[FrameworkBundle][Cache] PDO-based cache pool table autocreation does not work #29898
Closed
@errogaht

Description

@errogaht

Symfony version(s) affected: 4.2.2

Description
\Symfony\Component\Cache\Traits\PdoTrait has bug, auto creation of cache table is not working.

How to reproduce
Just use "symfony/cache": "^4.2" and default_pdo_provider: database_connection, try to call ->save() method and no cache table will be created, i am using pgsql
This is the place where table must be auto-created but not:

try {
    $stmt = $conn->prepare($sql);
} catch (TableNotFoundException $e) {
    if (!$conn->isTransactionActive() || \in_array($this->driver, array('pgsql', 'sqlite', 'sqlsrv'), true)) {
        $this->createTable();
    }
    $stmt = $conn->prepare($sql);
}

Possible Solution
Wrap with catch not prepare but execute method, when $stmt->execute(); called and no cache table exists TableNotFoundException will be throwed

Additional context
I have insered some code here to try the fix:
image

related: #27694 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0