DDC-3475: Avoid db connection in constructor #4283

Open
opened 2026-01-22 14:38:42 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 5, 2015).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user stefk:

Hi,

Since DBAL 2.5, calling *getDatabasePlatform* implies in most cases making a connection attempt (https://github.com/doctrine/dbal/blob/master/UPGRADE.md#bc-break-doctrinedbalconnection). Yet that method is called in the constructor of the SchemaTool class, which isn't very clean and can be problematic in some situations.

Are you open to a modification of that class to avoid this issue ? I can think of two workarounds :

  • initializing the platform attribute later
  • removing the attribute, retrieving the platform in getCreateSchemaSql and passing it to subsequent methods

I can send a PR if that's ok for you.

Originally created by @doctrinebot on GitHub (Jan 5, 2015). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user stefk: Hi, Since DBAL 2.5, calling **getDatabasePlatform\* implies in most cases making a connection attempt (https://github.com/doctrine/dbal/blob/master/UPGRADE.md#bc-break-doctrinedbalconnection). Yet that method is called in the constructor of the *SchemaTool** class, which isn't very clean and can be problematic in some situations. Are you open to a modification of that class to avoid this issue ? I can think of two workarounds : - initializing the **platform** attribute later - removing the attribute, retrieving the platform in **getCreateSchemaSql** and passing it to subsequent methods I can send a PR if that's ok for you.
admin added the Improvement label 2026-01-22 14:38:42 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 5, 2015):

@doctrinebot commented on GitHub (Jan 5, 2015): - relates to [DBAL-1057: Connection is not lazy anymore when guessing the platform is necessary](http://www.doctrine-project.org/jira/browse/DBAL-1057)
Author
Owner

@doctrinebot commented on GitHub (Jan 5, 2015):

Comment created by @deeky666:

See DBAL-1057.
We still don't know how to properly fix that issue, whether we can do something to make the connection lazier in DBAL already or if we have to adjust ORM / DoctrineBundle and possible other projects to avoid issues.
Currently it looks like we can't do much in DBAL so I tend to say that the complete ORM code has to be scanned for early platform retrieval and fixed to avoid possible issues.
[ocramius] [beberlei] thoughts?

@doctrinebot commented on GitHub (Jan 5, 2015): Comment created by @deeky666: See [DBAL-1057](http://www.doctrine-project.org/jira/browse/DBAL-1057). We still don't know how to properly fix that issue, whether we can do something to make the connection lazier in DBAL already or if we have to adjust ORM / DoctrineBundle and possible other projects to avoid issues. Currently it looks like we can't do much in DBAL so I tend to say that the complete ORM code has to be scanned for early platform retrieval and fixed to avoid possible issues. [<sub>ocramius] [</sub>beberlei] thoughts?
Author
Owner

@doctrinebot commented on GitHub (Oct 9, 2015):

Comment created by tomasz.janiczek:

Is there any progress on this? This impacts a lot of projects...

@doctrinebot commented on GitHub (Oct 9, 2015): Comment created by tomasz.janiczek: Is there any progress on this? This impacts a lot of projects...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4283