Inject a DB_NAME fallback for native WP-CLI commands#4005
Open
youknowriad wants to merge 1 commit into
Open
Conversation
A Studio site's wp-config.php often omits DB_NAME (Playground supplies the DB connection at runtime; pulled/imported or Playground-only sites can arrive without it). The v3+ SQLite drop-in requires a non-empty DB_NAME, so a one-off native WP-CLI command that boots WordPress — e.g. `plugin list` while building a full export's meta.json — fails with "Error establishing a database connection". This injects the same fallback the Playground path defines (`define('DB_NAME','wordpress')`) via WP-CLI's --exec, only when wp-config.php doesn't already define DB_NAME, so real values are never redefined.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
Collaborator
📊 Performance Test ResultsComparing eadf276 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
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.
Proposed Changes
Full-site export builds a
meta.jsonby running native WP-CLI commands (e.g.plugin list) that boot WordPress. On sites whosewp-config.phpomitsDB_NAME— common for pulled/imported sites, or sites only ever run under Playground (which supplies the DB connection at runtime) — the v3+ SQLite integration drop-in requires a non-emptyDB_NAME, so those commands fail with “Error establishing a database connection.”This injects the same fallback the Playground path already defines (
define('DB_NAME','wordpress')) into the native WP-CLI invocation via--exec— but only whenwp-config.phpdoesn't already defineDB_NAME, so a real value is never redefined and sites that define it are untouched.Testing Instructions
npm test -- apps/cli/lib/tests/run-wp-cli-command.test.ts(4 tests).wp-config.phphas noDB_NAMEand confirm it no longer errors on the DB connection.