Description
Symfony version(s) affected: 3.4.43+, 4.4.11+, 5.0.11+, 5.1.3+ and onward
Description
Due to #37342, when using the PDOAdapter for cache, the driver detection switched to an instanceof
approach. This is pretty unstable, due to the fact that wrapping the DBAL driver with your own implementation should be a fine approach, and it's even encouraged by the Middleware
interface introduced in DBAL 3: https://github.com/doctrine/dbal/blob/3.1.x/src/Portability/Middleware.php#L24-L31
How to reproduce
See getsentry/sentry-symfony#530, which was the original reported issue.
Possible Solution
Use $this->conn->getDatabasePlatform()->getName()
as a way to punch through the possible layers of wrapping middlewares and obtain a reliable platform name.
Additional context
I don't know the original reason for doing the original PR, since it's dubbed "fix compat for DBAL v3". @nicolas-grekas can you share some insights on that? Is there any reason to NOT take this approach?