pguetschow
pguetschow

Reputation: 5337

Symfony Cache Definition Problem with PDO Adapter

I am upgrading a Symfony 5.4 project to 6.2. While doing this, I encountered the following error:

Symfony\Component\Cache\Adapter\PdoAdapter::__construct(): Argument #1 ($connOrDsn) must be of type PDO|string, Doctrine\DBAL\Connection given

This is my Cache Config:

framework:
    cache:
        default_pdo_provider: 'doctrine.dbal.default_connection'
        pools:
            login_throttling.cache:
                adapter: cache.adapter.pdo

This worked in 5.4 and the docs for 6.2 are also suggesting that this config is correct: https://symfony.com/doc/current/cache.html

But the upgrade guide in the symfony github page has this information: https://github.com/symfony/symfony/blob/6.3/UPGRADE-6.0.md#cache

PdoAdapter does not accept Doctrine\DBAL\Connection or DBAL URL. Use the new DoctrineDbalAdapter instead

But it is unclear what the name for the new adapter is.

The whole approach is based on this: https://blog.digital-craftsman.de/login-throttling-with-symfony-and-multiple-server-instances/

Upvotes: 1

Views: 616

Answers (1)

pguetschow
pguetschow

Reputation: 5337

Solved. The correct config uses cache.adapter.doctrine_dbal instead of cache.adapter.pdo in the pool config.

Upvotes: 3

Related Questions