Repro
In a Studio site backed by Playground + SQLite drop-in:
wp db query "SELECT option_name FROM wp_options LIMIT 1"
Fatal:
Fatal error: Uncaught Error: Undefined constant "DB_HOST" in
phar:///tmp/wp-cli.phar/vendor/wp-cli/db-command/src/DB_Command.php:1798
Cause
wp db shells out to the mysql binary. The Playground SQLite stack defines no DB_HOST/DB_USER/DB_PASSWORD constants, and mysql isn't available in the runtime anyway. db-command tries to build a mysql --no-defaults … invocation using those constants and crashes before the missing-binary check.
Impact
Any agent or script that falls back to wp db query … for ad-hoc SQL against site state fatals. Affects anyone running Data Machine or Intelligence on Studio/Playground. Workaround (wp eval '$wpdb->get_results(...)') works but isn't obvious, especially to tooling that auto-reaches for wp db.
Suggested fix
Two reasonable options:
- In the SQLite integration: short-circuit
wp db subcommands with a clean "not available on SQLite — use wp eval or open the SQLite file directly" error. Graceful failure beats a fatal.
- Predefine stub
DB_* constants early in Playground's WP bootstrap so db-command at least errors with "mysql binary not found" instead of "undefined constant". Less clean but one-line.
Ideally route through (1) — wp db under SQLite should be a no-op with a clear message, not a crash.
Environment
- Playground
dev/combined-fixes + Studio dev/combined-fixes (Studio apps/cli wired to v3.1.20 tarballs from a local self-host)
- wp-cli 2.12.0 (from the Playground-bundled
wp-cli.phar)
- PHP 8.3, SQLite integration via MDI's db.php drop-in (behavior is the same with stock sqlite-database-integration drop-in per earlier observation)
Repro
In a Studio site backed by Playground + SQLite drop-in:
Fatal:
Cause
wp dbshells out to themysqlbinary. The Playground SQLite stack defines noDB_HOST/DB_USER/DB_PASSWORDconstants, andmysqlisn't available in the runtime anyway.db-commandtries to build amysql --no-defaults …invocation using those constants and crashes before the missing-binary check.Impact
Any agent or script that falls back to
wp db query …for ad-hoc SQL against site state fatals. Affects anyone running Data Machine or Intelligence on Studio/Playground. Workaround (wp eval '$wpdb->get_results(...)') works but isn't obvious, especially to tooling that auto-reaches forwp db.Suggested fix
Two reasonable options:
wp dbsubcommands with a clean "not available on SQLite — usewp evalor open the SQLite file directly" error. Graceful failure beats a fatal.DB_*constants early in Playground's WP bootstrap so db-command at least errors with "mysql binary not found" instead of "undefined constant". Less clean but one-line.Ideally route through (1) —
wp dbunder SQLite should be a no-op with a clear message, not a crash.Environment
dev/combined-fixes+ Studiodev/combined-fixes(Studio apps/cli wired tov3.1.20tarballs from a local self-host)wp-cli.phar)