mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #1471] Platform built twice on closed connections #9530
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/1471
State: closed
Merged: No
There is a loop when a closed connection is asked for its Database Platform, in which the resulting Platform object gets overwriten by a new one and all modifications made in the postConnect event are lost.
The commited test adds the event BEFORE the connection gets opened automatically by the OrmFunctionalTestCase setUp method. I know this is not a common test scenario, but I had to make this hack in order to reuse all the other FunctionalTestCase stuff.
I believe this only happens in Drivers that implement VersionAwarePlatformDriver, as I could not reproduce it with sqlite.
I believe what's happening is:
Connectiontries todetectPlatformDrivergetDatabasePlatformVersiontries to$this->connect()itConnection::connect()has anullon$this->platformbecause it didn't finish detecting, so it tries to detect againdetectPlatormDriversuccedes.Connectionfires the eventdetectPlatformDrivercall executes, overriding$this->platformI was using the postConnect event to add types only when the connection is opened, instead of adding them every time I constructed the EntityManager, to prevent connections from being opened every time.