DDC-3842: [GH-1471] Platform built twice on closed connections #4705

Open
opened 2026-01-22 14:48:01 +01:00 by admin · 0 comments
Owner

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:

  • Connection tries to detectPlatformDriver
  • As connection is closed, getDatabasePlatformVersion tries to $this->connect() it
  • Connection::connect() has a null on $this->platform because it didn't finish detecting, so it tries to detect again
  • This time the connection is opened, so detectPlatormDriver succedes.
  • Connection fires the event
    ** The rest of the first* detectPlatformDriver call executes, overriding $this->platform

I 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.

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: - `Connection` tries to `detectPlatformDriver` - As connection is closed, `getDatabasePlatformVersion` tries to `$this->connect()` it - `Connection::connect()` has a `null` on `$this->platform` because it didn't finish detecting, so it tries to detect again - This time the connection is opened, so `detectPlatormDriver` succedes. - `Connection` fires the event *\* The rest of the _first_\* `detectPlatformDriver` call executes, overriding `$this->platform` I 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.
admin added the Bug label 2026-01-22 14:48:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4705