Skip to content
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

DriverManager::getConnection does not accept an existing PDO object as a configuration option. #4504

Closed
rhift opened this issue Feb 22, 2021 · 11 comments · Fixed by #4615
Closed

Comments

@rhift
Copy link

rhift commented Feb 22, 2021

Bug Report

Q A
BC Break ?
Version 3.0.0

Summary

\Doctrine\DBAL\DriverManager::getConnection does not accept an existing PDO object as a configuration option.

I'm not sure if this support was removed in 3.0.0 or if this is a bug. I'm really hoping it's a bug since I won't be able to use 3.0.0 in the case that it's not supported. =)

I think it's a bug since the 3.0.0 documentation is the same API as the 2.x series (or I guess it could be a documentation c&p issue).

Thank you!

Current behaviour

When using

DriverManager::getConnection(['pdo' => new \PDO(/* constructor options */)]);

\Doctrine\DBAL\Exception is thrown with the message "The options 'driver' or 'driverClass' are mandatory if no PDO instance is given to DriverManager::getConnection().".

How to reproduce

Execute

DriverManager::getConnection(['pdo' => new \PDO(/* constructor options */)]);

Notice that \Doctrine\DBAL\Exception is thrown with the message "The options 'driver' or 'driverClass' are mandatory if no PDO instance is given to DriverManager::getConnection().".

Expected behaviour

No Throwable is thrown and DriverManager::getConnection returns a viable connection. (i.e. it works as it does in 2.12.1)

@andrew-demb
Copy link
Contributor

See upgrade docs: https://github.com/doctrine/dbal/blob/3.0.0/UPGRADE.md#bc-break-user-provided-pdo-instance-is-no-longer-supported

@rhift
Copy link
Author

rhift commented Feb 22, 2021

Thanks @andrew-demb!

I have a use case where my runtime wants to use a PDO from another runtime. Which is (obviously) different from the solution provided in the upgrade document where my runtime tells the other runtime to use the PDO that it is using with Doctrine. Since the other runtime is free to choose their ORM/DBAL vendor provided that it uses a PDO it's more attractive to me to have the other runtime provide the one that it is using.

However, even if the other runtime was using Doctrine, it's unclear to me how it would then use the PDO my runtime would provide since that then presents this same problem. As far as I can tell I would have to require the other runtime to use Doctrine (and then share Doctrine specific connections), which is not attractive to me for what I'm trying to accomplish.

Are there any current APIs (or plans to create new APIs) to instruct Doctrine to use an existing PDO like in previous versions of DBAL? If not this BC breaking change is pretty significant for me. =/

Regardless, just a friendly reminder that the documentation needs updating. =)

Really appreciate the help and all the work put it into Doctrine over the years! Thanks again!

@DarkGhostHunter
Copy link

Same problem here. No pdo option, even when the docs say it. This should be removed from the docs then.

@greg0ire
Copy link
Member

A solution mentioned here would be to implement your own driver: #3554

@greg0ire
Copy link
Member

Regardless, just a friendly reminder that the documentation needs updating

This should be removed from the docs then.

Fine! I opened a PR to remove this from the docs, but you could have done so yourselves, you know? I mean friendly reminders are great, but friendly PRs are also very much appreciated 😉

@rhift
Copy link
Author

rhift commented Apr 22, 2021

@greg0ire - lol I didn't really care at all, I had moved on, just wanted y'all to know that you had a c&p error, but I promise not to give you friendly reminders from now on.

@greg0ire
Copy link
Member

I didn't really care at all, I had moved on

Yes, that's the issue I was pointing at. You got some help with your issue, and didn't think of giving back. Well to be fair, the reminder is still appreciated, just… it feels a bit like piling work on the collective desk. We get a lot of +1, and "me too" and reminders like that. Feels nice to get PRs instead once in a while. So next time, please consider it 🙏

@rhift
Copy link
Author

rhift commented Apr 22, 2021

wow. "got some help with your issue, and didn't think of giving back"??? - lol I would consider "see upgrade docs" equivalent to the effort of me pointing out that the documentation was incorrect. if your behavior is indicative of the Doctrine community y'all have some cultural problems to work at making better. goodness, dial back the pedantic rhetoric

@greg0ire
Copy link
Member

You're right, I'm sorry. I could have asked nicely. I guess I got angry because I read another issue right before where several people were complaining that something had not been implemented for years, and they could not fathom how that was even possible. Too much OSS I guess.

if your behavior is indicative of the Doctrine community y'all have some cultural problems to work at making better

Nah that's just me thankfully.

@rhift
Copy link
Author

rhift commented Apr 22, 2021

np, thanks, and being unappreciated feels terrible when you put so much into something, I get it =) thanks for your contributions to OSS, and best of luck in the future

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants