Skip to content

Pdo sub classing rough WIP #8707

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 35 commits into from
Closed

Conversation

Danack
Copy link
Contributor

@Danack Danack commented Jun 4, 2022

This is just a initial commit, to trigger the full PHP test suite. Obviously needs an RFC writing.

For the record, I know some code is in the wrong place currently. Will put stuff in the right place before changing the PR from draft.

@alecpl
Copy link

alecpl commented Jul 11, 2023

I see PdoMySql with upper case S in some places. You should use lower case consistently. Also the RFC has that small issue.

@Danack
Copy link
Contributor Author

Danack commented Jul 11, 2023

Thanks.

I saw and fixed them in ext/pdo_mysql/tests/subclasses/pdomysql_001.phpt Did you see any others?

@alecpl
Copy link

alecpl commented Jul 11, 2023

You could also change it for MySQLPDOTest, I suppose. I came here from the RFC where I saw the issue initially.

@Girgias Girgias marked this pull request as ready for review July 18, 2023 02:06
@Girgias Girgias requested a review from kocsismate as a code owner July 18, 2023 02:06
@Girgias Girgias marked this pull request as draft July 18, 2023 02:06
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Did a cursory review (and messed up by marking this as ready...).

Seems this requires a rebase to retrigger CI.

memcpy(&pdosqlite_dbh_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
pdosqlite_dbh_object_handlers.offset = XtOffsetOf(pdo_dbh_object_t, std);
pdosqlite_dbh_object_handlers.free_obj = pdo_dbh_free_storage;
pdosqlite_dbh_object_handlers.clone_obj = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need to specify the clone handler IIRC as it is NULL by default? Same as the compare handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the clone_obj. Not sure what you meant for the compare handler, as that is not set to NULL.

PHP_METHOD(PDO, __construct)

#define MAX_PDO_SUB_CLASSES 64
static int number_of_pdo_driver_class_entries = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Could be unsigned int

Copy link
Contributor Author

Choose a reason for hiding this comment

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

k.

Comment on lines 324 to 328
// could this ever happen?
if (driver->driver_name == NULL) {
zend_throw_exception_ex(php_pdo_get_exception(), 0, "Driver name is NULL");
RETURN_THROWS();
}
Copy link
Member

Choose a reason for hiding this comment

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

I would ZEND_ASSERT() this as not having a name is a bug in the implementation of the driver.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so like:

ZEND_ASSERT((driver->driver_name != NULL) && "PDO driver name is null");

?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that would do the trick!

// I chose not to, as that would cause BC break and require a lot of
// downstream work.
typedef struct {
char *driver_name;
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it makes sense to have this be a zend_string that is interned by the driver on startup. But that can be a future improvement.

Comment on lines +8 to +12
/**
* @var int
* @cname PDO_PGSQL_ATTR_DISABLE_PREPARES
*/
public const ATTR_DISABLE_PREPARES = UNKNOWN;
Copy link
Member

Choose a reason for hiding this comment

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

@kocsismate does it make sense to move the type information into the constant declaration now that we have typed constants?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

Comment on lines +54 to +58
if (!tmp) {
// TODO - exception
php_error_docref(NULL, E_WARNING,"Failed to escape identifier");
RETURN_FALSE;
}
Copy link
Member

Choose a reason for hiding this comment

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

Obviously this has a TODO but this currently will fail ZPP return type checks

Comment on lines +8 to +12
/**
* @var int
* @cname SQLITE_DETERMINISTIC
*/
public const DETERMINISTIC = UNKNOWN;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto same comment about moving the type info into the constant declaration.

@Danack
Copy link
Contributor Author

Danack commented Jul 18, 2023

Closed in preference for #11740

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.

5 participants