-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.8.13] 'SQLSTATE[HY000] [2002] Connection refused' if docktrine/dbal installed #28282
Comments
This is caused by #28214. /cc @JacksonIV We should only call |
@staudenmeir I’ll look into this. 👍🏼 |
I have tried a few things but I can't seem to reproduce this on a new laravel installation. Could you please provide me with some more information as where you encounter this error? Are you sure your database credentials and settings are correct? Also, please make sure you are running:
instead of:
|
The error only happens when a database connection is not available. Something like |
@staudenmeir Everything seems to work fine here, even without a connection. Maybe i'm doing something wrong though. Can you reproduce this on your Laravel installation?
|
Yes, I can reproduce it:
I can trigger the error with |
The constructor does get called. Take a look at |
@staudenmeir I still have a hard time understanding how this can happen since the connection is first instantiated there? |
@driesvints When the custom DBAL types get registered in the builder’s constructor it tries to find a Doctrine connection. If there’s no Doctrine connection, it will try to instantiate one. But if the database credentials or settings are incorrect it will throw a PDO exception. If the database settings and credentials are correct, there’s no problem though. This could indeed be fixed by moving the actual registration to the migrator. I will try to fix this as soon as i can, but unfortunately i’m a little short on time currently. |
On the other hand, if you are calling the schema facade, you’d probably want a working database connection, right? |
@driesvints The facade only instantiates an instance of the Is that what you mean? |
@JacksonIV Probably, but not necessarily immediately. Only instantiating an instance of a class like |
@staudenmeir I see what you mean. It's imperative that we get this fixed soon though. Otherwise it's best that we revert for now. |
@driesvints Instead of reverting everything, i could make a PR which removes the registration of the custom DBAL types in the constructor of the MySQL builder. This way people can still call the |
I would revert it. Then we can take the time to fix this properly and also cover the other databases (#28214 (comment)). |
@staudenmeir You're right, i'll start working on a proper fix as soon as possible. I'll also try to cover the other databases simultaneously! Sorry for the hassle! |
I've removed the method call in the constructor for now and this will be released tomorrow. Please send in a better solution as soon as you're able to, thanks! |
@driesvints this also breaks the After applying your revert from #28301 it started working again. Hopefully this can be tagged soon and properly addressed later. :) |
I also receive this error if I call getDoctrineSchemaManager() within my console command constructor with laravel 6.2 and doctrine/dbal ^2.10
As soon as I move this call to the handle() method, it works as expected. |
I receive this error when I call composer install! |
Description:
You can't run
composer update
and callartisan
commands if addSchema::defaultStringLength
calling toAppServiceProvider
and you havedoctrine/dbal
package.On running
composer require doctrine/dbal
:On 5.8.12 works fine.
Steps To Reproduce:
1071 Specified key was too long
error:Using official documentation: https://laravel.com/docs/5.8/migrations#indexes
Add
Schema::defaultStringLength
calling toAppServiceProvider
doctrine/dbal
package:You will get error:
The text was updated successfully, but these errors were encountered: