-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DBAL-1057 Connection is not lazy anymore when platform detection is necessary #990
Comments
|
Comment created by stof: Actually, the Connection class itself defers the guessing until the first time the platform is accessed. But many places in DBAL and in the ORM are retrieving the platform and storing it in a property of the class at instantiation time to avoid method calls when they need to access the platform. So this might be much harder to fix |
Comment created by @deeky666: [~stof] Can we analyze the use cases where retrieving the platform is necessary before actually connecting? I only know the custom type registering so far... Maybe we can defer that somehow? |
Comment created by stof: [~deeky666] the issue is that many places in DBAL and the ORM are retrieving the connection before they use it. the Connection class itself in DBAL is already deferring the guessing |
Comment created by @deeky666: [~stof] I know that. The question is WHY do those defered connections need to access Connection::getDatabasePlatform() without connecting? What are the use cases? |
Comment created by stof: [~deeky666] The issue is that all those objects are calling |
Comment created by stof: and the issue is precisely that all these parts of Doctrine are _not_ deferring the retrieval of the platform. |
Comment created by steffenbrem: This is causing a lot of issues when using CI servers. Where it is very important that those things are lazy, since you do not have the database configured on most applications that build on a CI server. |
Comment created by craigh: This is also an issue for the project I am working as I am trying to use Symfony to to generate forms and so on in order to install the project. sForms and the main project's front controller trigger DI events and trigger this error. The workaround mentioned here (doctrine/DoctrineBundle#351 (comment)) fixes the problem but this cannot be a long term solution. I look forward to the fix for this issue. |
Comment created by alanhartless: I have the same issue as Craig. This poses a major hassle for applications that have an installer UI. We have a Symfony based application that gives the user options to configure the database such as driver, table, credentials, etc. Then the application will make a dynamic connection to check database, install data, etc. Eventually Symfony's cache is cleared to use the new credentials post install. Because of this, the installer fails out of the box since it can't connect to the server. We can't use the work around as mentioned above because of giving the option to choose what driver to use in the installer. Thanks, |
Comment created by craigh: Tried an experiment today. As noted in the workaround you can set the server_version: 5.1 (or whatever your version is). Well, my version is 5.5 so I originally used that. Today I tried 5 and 52 and 1 and they all worked! so it seems that the actual version doesn't matter (at least when I need them, which is before_ I've actually set up the DB credentials) as long is there is _some value. |
Comment created by @deeky666: [~craigh] this is expected behaviour. You can theoretically specify any value you want, DBAL will try to find the appropriate platform for you by the specified version via version compare. |
Comment created by rosier: Doctrine now also throws a connection exception when it tries to detect the database platform, but can't make a connection to the server. Even if the connection isn't really used. I think it would be better to do a fallback to the "default" platform in that case and only throw an connection exception if the connection is required for something else than guessing the platform. For example if you haven't set up the DB credentials yet and only call Doctrine\DBAL\Connection::getDatabasePlatform() you get the "default" platform. |
This still happens, and I don't know if I have to put when using Shall I use This "bug" makes Symfony 2.8 application not bootable without an access to the database |
@tristanbes we currently have no distinction for MariaDB servers. DBAL currently checks for substring Hope this helps for now. |
thanks @deeky666 |
I am seeing the issue on AWS even with the server_version set. I get "php_network_getaddresses: getaddrinfo failed:" error message. The database we use is on AWS is MariaDB. |
I'd need a stack trace to understand the issue then...
|
@Ocramius Apologies should have explained more. Using Symfony3 with Doctrine 2.5. I've included the important parts of the stack trace. In this case the application tried to do a query for a login request and it barfs with the attached The config.yml has the version specified as below:
This works fine for MySQL on my local machine but when the application is in AWS it doesn't work. Thanks. |
Since you use Symfony, could you pleas continue the discussion on the
|
@Ocramius will do. |
you must set the database software version in the config.yml file.
…fallback fixes doctrine#990: try platform detection without database name as fallback
Handled in #2671 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Jira issue originally created by user stof:
In DBAL 2.5, many driver can rely on different versions of the platform. Unless the version is explicitly provided, the driver will guess it at instantiation time, killing the lazyness of the connection.
This is a critical issue in any context using DI as it means that injecting the connection into anything else will connect to the server.
The text was updated successfully, but these errors were encountered: