mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3842: [GH-1471] Platform built twice on closed connections #4705
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?
Originally created by @doctrinebot on GitHub (Jul 21, 2015).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user @doctrinebot:
This issue is created automatically through a Github pull request on behalf of guiwoda:
Url: https://github.com/doctrine/doctrine2/pull/1471
Message:
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 is 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 event** The rest of the first*
detectPlatformDrivercall 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.