-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Pdo subclassing #11740
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
Pdo subclassing #11740
Conversation
Needs thinking about ini settings.
Added ability to register driver specific classes.
Tests don't currently work due to mssql server not running on my computer.
RECREATE will drop (if needed) before creating
…on the PdoPgsql class.
Made extension loading work and implemented exceptions.
public static function connect( | ||
string $dsn, | ||
?string $username = null, | ||
?string $password = null, |
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.
Might fix some of the tests
?string $password = null, | |
#[\SensitiveParameter] | |
?string $password = null, |
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.
Do you mean php-src/ext/pdo/tests/sensitive_parameter.phpt? If so, I think that might not be my fault, as I haven't touched that test.
But yes, that probably should be there, and a test for it.
@Girgias I'm just waiting for CIs to run....They appear to have built, and I think invoking One thing that is odd is that the PDO class itself now has all the parameters auto-generated....which apparently they weren't before. Which is a bit confusing. |
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_PDO_connect, 0, 1, PDO|PDOSqlite, 0) | ||
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0) | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, username, IS_STRING, 1, "null") | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null") | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") | ||
ZEND_END_ARG_INFO() | ||
|
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.
Yeah I don't know why in a previous iteration the constants were not declared any more in the arg info.
$extension_location = null; | ||
$locations = [ | ||
'/usr/lib/aarch64-linux-gnu/mod_spatialite.so', | ||
"/usr/lib/x86_64-linux-gnu/mod_spatialite.so" |
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.
On Alpinelinux it living in /usr/lib/mod_spatialite.so
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.
ok, thanks.
Loading non-existent file. | ||
Unable to load extension '/this/does/not_exist' | ||
Loading invalid file. | ||
Unable to load extension '%s: cannot open shared object file: No such file or directory' |
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.
On Alpinelinux it fails with
========DIFF========
Loading non-existent file.
Unable to load extension '/this/does/not_exist'
Loading invalid file.
004- Unable to load extension '%s: cannot open shared object file: No such file or directory'
004+ Unable to load extension 'Error loading shared library /mnt/testing/php83/src/php-src-791ca5d1dbc5cbb4a76dbb9942dd78860827264f/ext/pdo_sqlite/tests/subclasses/pdosqlite_load_extension_failure.php.so: No such file or directory'
Fin.
========DONE========
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.
Ok thanks. I relaxed the test criteria so it should pass, but it's probably not super great that the error message apparently varies based on SQLite version.
/** @generate-class-entries */ | ||
|
||
/** @not-serializable */ | ||
class PdoMysql extends PDO |
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.
I'm wondering if we should use the same casing as the original class: e.g. PDOMySql
etc.?
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.
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.
Exact spelling of class names is an aesthetic choice, so it's fine for everyone to have their own opinion, and normal for people to be able to conjure up arguments that just so happy to support their own gut instinct. Which I will now do.
I personally chose the one in the RFC as Tim convinced me that "ucfirst(strtolower(...)) for acronyms" as PCGOneseq128XSLRR64
is almost as horrible as PdOsQlItE
.
I'm also pretty sure that having the class name (not just the namespace) contain Pdo is going to make the class easier to google as PdoMysql
will be treated as a single word by search engines, whereas Pdo\Mysql
is treated as two words, and will be more likely to bring up all of the existing pages that talk about PDO and MySQL, rather than the new manual page for the new class.
|
||
/** @generate-class-entries */ | ||
|
||
/** @not-serializable */ |
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.
Nit: You could add a @strict-properties
tag so that it already forbids dynamic properties
So, anyone seen a release manager, and is this able to get into PHP 8.3? As I mentioned the other day I am feeling "not great" from being in constant pain. I can do a tiny bit more to get this across the line, but if people have nits or want to change stuff....can you just do that after merging so I don't have to spend any more time thinking about this? Or if it's not going in 8.3 those changes can wait 6 months. Either way, I've really close to the limit of what I can contribute for this RFC for the time being. |
So I learned this yesterday, by going through our release process file for unrelated reasons but:
c.f. https://github.com/php/php-src/blob/master/docs/release-process.md#feature-freeze so RMs should be willing to accept this post FF... which now I'm wondering why we were rushing PRs to get them merged before beta1 |
Probably because of trauma related to drama. |
Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
Just a note here that it should be fine to accept such changes during beta but we need to draw some line when this can be accepted and for me it is the first RC which signals ABI freeze and has been already tagged. So I don't think this can be accepted to 8.3. It will have to wait till 8.4 so you have plenty of time to finish the implementation. |
Yeah, I haven't looked at this again but I don't understand the phpdbg issue |
?string $username = null, | ||
?string $password = null, | ||
?array $options = null | ||
): PDO|PDOSqlite {} |
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.
|PDOSqlite
might be a leftover from initial attempts, I think they all extend PDO now (?)
@bukka fyi, I'm actually not that well due to a chronic pain problem. I'm not going to be able to work on this probably this year. If the PHP project (or PHP Foundation) has a 'contributor has been bus-factored' process, it would be good to activate that. If there isn't a 'bus-factored' policy....maybe it's time for one. |
@Danack Sorry to hear that. Hope you feel better soon. I will raise it during our next meeting and we should hopefully get it all sorted out. |
Superseded by #12804 |
Implementation of https://wiki.php.net/rfc/pdo_driver_specific_subclasses