-
-
Notifications
You must be signed in to change notification settings - Fork 150
Add polyfill for PDO driver specific subclasses #549
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
base: 1.x
Are you sure you want to change the base?
Add polyfill for PDO driver specific subclasses #549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add the static connect method to every child class, since we can polyfill it there?
How does this method behave when given a DSN for another driver and when it's called on a child class?
325af09 to
f0b0b10
Compare
We could, but that feels a bit off to me. The whole idea of the |
|
About the connect method on child classes, I'd still add it, for completness of the polyfill |
97852db to
8034458
Compare
|
I probably will look into the last bits next week; if anyone is eager to finalize on the |
But if you are on PHP 8.4, would you really call the constructor of those subclasses instead of |
8034458 to
a89fdfe
Compare
To be fair, if one is currently only using something like |
ecd99c0 to
f42017a
Compare
|
I think this should be complete now as is. Additional feature-like tests could be nice, but on the other hand are probably very hard to implement in practice without any real database and I think the current set should suffice to prove this should work in practice. In particular the migration towards 'polyfilled' constants should be very safe to do with this. |
As a follow-up to #547, this PR aims to implement a full-fledged set of polyfills for the driver specific PDO subclasses introduced in PHP 8.4; see also https://wiki.php.net/rfc/pdo_driver_specific_subclasses.
As of PHP 8.5, the driver specific constants and methods available on the base
PDOclass will be deprecated, to be removed in PHP 9.0. See also https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods.This PR adds a polyfill to use the driver-specific child classes for PHP versions prior to PHP 8.4. This in turn allows one to already refer to the 'new' constant, to prevent deprecation errors on PHP 8.5, while retaining backwards compatibility. This can be particularly useful for code requiring support for multiple versions; see e.g. laravel/framework#57141.
The classes should be suitable for constructing on older PHP versions.
Note the
PDO::connectstatic method that has been introduced simultaneously has not been polyfilled, as I can't think of a proper way to do such a thing currently.