-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected
5.1.8 and up
Description
When using the DoctrineTransport with PostgreSQL, the queue table is created with a trigger to enable LISTEN/NOTIFY feature.
This is done by checking if the driver is an instance of AbstractPostgreSQLDriver
.
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php
Lines 51 to 55 in acf1f71
if ($useNotify && $driverConnection->getDriver() instanceof AbstractPostgreSQLDriver) { | |
$connection = new PostgreSqlConnection($configuration, $driverConnection); | |
} else { | |
$connection = new Connection($configuration, $driverConnection); | |
} |
This check won't work though, if the driver is decorated. This then leads to missing trigger to use the LISTEN/NOTIFY feature.
How to reproduce
I experienced this when when having sentry/sentry-symfony
installed.
My sentry.yaml
looks like this:
sentry:
dsn: "%env(SENTRY_DSN)%"
register_error_listener: false
options:
environment: "%env(SENTRY_ENV)%"
# release: "%env(VERSION)%" #your app version
monolog:
handlers:
sentry:
type: sentry
level: !php/const Monolog\Logger::ERROR
hub_id: Sentry\State\HubInterface
Possible Solution
Currently the check is done by checking the instance of the driver in the DoctrineTransportFactory.
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/DoctrineTransportFactory.php
Line 51 in acf1f71
if ($useNotify && $driverConnection->getDriver() instanceof AbstractPostgreSQLDriver) { |
Instead of checking the Driver itself, we might get the platform and check if the platform is of type PostgreSQLPlatform
like so:
if ($useNotify && $driverConnection->getDriver()->getDatabasePlatform() instanceof PostgreSQLPlatform) {
Is this a viable solution or do I miss something here?
Additional Context
No response