Skip to content

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

Closed
wants to merge 53 commits into from
Closed

Pdo subclassing #11740

wants to merge 53 commits into from

Conversation

Danack
Copy link
Contributor

@Danack Danack commented Jul 18, 2023

Danack and others added 30 commits July 18, 2023 13:02
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
Made extension loading work and implemented exceptions.
public static function connect(
string $dsn,
?string $username = null,
?string $password = null,
Copy link
Member

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

Suggested change
?string $password = null,
#[\SensitiveParameter]
?string $password = null,

Copy link
Contributor Author

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.

@Danack
Copy link
Contributor Author

Danack commented Jul 18, 2023

@Girgias I'm just waiting for CIs to run....They appear to have built, and I think invoking extern ZEND_API also fixed the issue with building the pdo_* extensions as shared.

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.

Comment on lines +11 to +17
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()

Copy link
Member

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"
Copy link
Contributor

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

Copy link
Contributor Author

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'
Copy link
Contributor

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========

Copy link
Contributor Author

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
Copy link
Member

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.?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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 */
Copy link
Member

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

@Danack
Copy link
Contributor Author

Danack commented Jul 19, 2023

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.

@Girgias
Copy link
Member

Girgias commented Jul 19, 2023

So I learned this yesterday, by going through our release process file for unrelated reasons but:

The feature freeze for php-src means that we will not accept any new features after the date of the feature freeze. For any RFCs to be included in the new version, they should be discussed and have the voting polls closed no later than the feature freeze date. However, this does not mean the new feature must have a complete implementation by this date.

Following the feature freeze, the focus of work for the new version will be on fixing bugs, writing tests, and completing/polishing all accepted features.

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

@Danack
Copy link
Contributor Author

Danack commented Jul 19, 2023

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>
@bukka
Copy link
Member

bukka commented Aug 31, 2023

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.

@Girgias
Copy link
Member

Girgias commented Sep 2, 2023

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 {}
Copy link

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 (?)

@Danack
Copy link
Contributor Author

Danack commented Sep 10, 2023

@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.

@bukka
Copy link
Member

bukka commented Sep 10, 2023

@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.

@Girgias
Copy link
Member

Girgias commented Dec 27, 2023

Superseded by #12804

@Girgias Girgias closed this Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants