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

Add db_server_info method #63

Merged
merged 1 commit into from
Feb 16, 2023
Merged

Add db_server_info method #63

merged 1 commit into from
Feb 16, 2023

Conversation

nateweller
Copy link
Contributor

@nateweller nateweller commented Feb 16, 2023

This PR adds a mock method to override $wpdb->db_server_info() in dbless-wpdb.php.

The purpose of this is to allow graceful execution of dbDelta() in WorDBless test cases.

Currently, the dbDelta function calls $wpdb->db_server_info(), which will end up calling mysql_get_server_info(), which fatals. The reasons mysql_get_server_info breaks will either be due to the fact that it was removed in PHP 7.0.0, or if you're running an earlier version of PHP, because the method expects $wpdb->dbh to not be false or null.

Would this be a useful addition? While this doesn't necessarily add support for using dbDelta in WorDBless, it does prevent it from breaking when the function is executed inside a WorDBless test case.

Copy link
Collaborator

@szepeviktor szepeviktor left a comment

Choose a reason for hiding this comment

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

Hello!
Seems like a useful addition.

@szepeviktor szepeviktor changed the title DBLess WPDB: Add db_server_info method Add db_server_info method Feb 16, 2023
@nateweller nateweller merged commit f5659d8 into master Feb 16, 2023
@nateweller nateweller deleted the add/wpdb-mock-server-info branch February 16, 2023 23:50
@szepeviktor
Copy link
Collaborator

Why not return a valid MySQL version as in db_version()?

@nateweller
Copy link
Contributor Author

nateweller commented Mar 15, 2023

Why not return a valid MySQL version as in db_version()?

This seems more appropriate since WorDBless is already in the practice of mocking a specific database environment. Most of the use cases for db_server_info() is for handling special cases surrounding MariaDB, so I don't see any potential issues.

@szepeviktor
Copy link
Collaborator

Thank you.

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.

2 participants