Add wpdb fallback for wp db query when mysql/mariadb binary is unavailable#320
Draft
Add wpdb fallback for wp db query when mysql/mariadb binary is unavailable#320
wp db query when mysql/mariadb binary is unavailable#320Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…lable Agent-Logs-Url: https://github.com/wp-cli/db-command/sessions/8996fc65-2840-4792-8cf4-ddc700a7c040 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wp-cli/db-command/sessions/8996fc65-2840-4792-8cf4-ddc700a7c040 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix wp db query to fallback using WPDB
Add wpdb fallback for Apr 2, 2026
wp db query when mysql/mariadb binary is unavailable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wp db querycurrently requires themysql/mariadbCLI binary, causing failures with drop-in database engines (HyperDB, custom drivers) or environments where the binary simply isn't installed.Changes
src/DB_Command.phpis_mysql_binary_available()— probes for the mysql/mariadb binary via/usr/bin/env <binary> --version; result is statically cachedmaybe_load_wpdb()— loads the minimal WordPress files needed for$wpdb(compat.php,plugin.php,functions.php,class-wpdb.php), includes anywp-content/db.phpdrop-in (HyperDB et al.), and falls back to creating a plainwpdbinstance with wp-config.php credentials +$table_prefixwpdb_query()— executes arbitrary SQL via$wpdb; mirrors the mysql-path behaviour (row-count reporting for DML, formatted tabular output for SELECT,--skip-column-namessupport)query()— after the existing SQLite branch, checks binary availability and routes to the new wpdb path when absent:features/db-query.featureAdded a
@require-mysql-or-mariadbscenario that shadows the real binary with a fakeexit 127script viaPATHprepending, then asserts the query succeeds and the debug message confirms the fallback was taken.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/usr/bin/php /usr/bin/php /home/REDACTED/work/db-command/db-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email hp kFunctions.php .php�� ain..copilot/fix-wp-db-query-fallback ss.php k/_temp/copilot-developer-action-main/dist/gh-gpgsign/gh-gpgsign-linux-x86_64 mmand.php Autoloader.php de/node/bin/git k/_temp/copilot-developer-actionanalyse(dns block)/usr/bin/php /usr/bin/php /home/REDACTED/work/db-command/db-command/vendor/wp-cli/wp-cli/bin/../php/boot-fs.php core install --url=REDACTED --title=WP CLI Site --admin_user=admin --admin_email=admin@example.com --admin_password=password1 --skip-email ools/sh git rev-�� ain..copilot/fixOUTPUT cut command/vendor/b168.63.129.16 ain..copilot/fixphp(dns block)If you need me to access, download, or install something from one of these locations, you can either: