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

Ensure wp core functions exist before using them #135

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

jeroenpf
Copy link
Contributor

In this PR I propose that we always check if a wp core function is defined before attempting to use it, as we do in the constructor of the Translator class.

Several hooks (do_action, apply_filters) are used in the WP_SQLite_Translator class. The class may be used in a context where WordPress is not loaded.

We are currently working on adding support for SQLite to the WP Cli import and export commands and intend to use the translator to execute various SQL statements. Those commands run in a context where WordPress has not been loaded so do_action and apply_filters are unavailable.

@jeroenpf
Copy link
Contributor Author

@bgrgicak This one is not urgent but if you have time I'd appreciate your feedback on this one. Ideally, the heavy lifting (i.e. translating queries) would not depend on WordPress core functions so that it is easier to reuse the logic in other places where WP is not loaded (e.g. the wp cli db import command).

@aristath aristath merged commit 3dfb82e into WordPress:develop Jul 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants