Description
Description
After #34066, the Doctrine middleware should now work nicely.
In fact, I think that the "clear entity manager" and "ping connection" middleware should ALWAYS be used (assuming Doctrine is installed). Both of these are very sensible things to do to make sure the database connection is alive and that data in the entity manager isn't "stale" because it's being stored in an identity map that was added to via a message handled 10 minutes ago.
There are 2 tricky parts to this:
-
The services for those middleware are added via DoctrineBundle... but the default middleware need to be added in FrameworkExtension.
-
Would we do it for all entity managers? I think that could (in https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bridge/Doctrine/Messenger/DoctrinePingConnectionMiddleware.php) cause connections to be made to all connections, even if a connection wasn't previously open (though, that could be fixed by only pinging a connection
if $connection->isConnected()
).